Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
cb5daf3
SI-9665 Backquoted vbar in extractor pattern
som-snytt Feb 21, 2016
5fd8483
Added applyOrElse to MapLike
kilotaras Mar 20, 2016
9ec6278
SI-9760 Fix for higher-kinded GADT refinement
milessabin Apr 19, 2016
fa65623
Added missing result type to test.
milessabin Apr 20, 2016
5faad77
Added pos test with multiple cases; added neg tests.
milessabin May 6, 2016
b58634e
Improves the test cases for the scala-concurrent-tck
viktorklang Apr 5, 2016
45e607d
SI-9361 fixed assert allowing display of improved error message.
milessabin May 14, 2016
139f9a0
Make Range.Partial a value class
xuwei-k May 17, 2016
883fdd7
SI-5463 Check .jars before using them
May 10, 2016
214ea82
SI-9656 Range.toString distinguishes Numeric step
Feb 27, 2016
3cddeaa
SI-7916: ScriptEngine support
som-snytt Sep 14, 2015
80d996b
Include missing web assets in scaladoc
jodersky Apr 11, 2016
6be9fc6
SI-9781 Don't convert erroneous expression to assignment
liff May 19, 2016
481a390
Improvements to scala.concurrent.Future
viktorklang May 13, 2016
f7b575d
Merge pull request #5093 from jodersky/scaladoc-include-assets
szeiger May 20, 2016
72a59d9
Rename nsc.backend.jvm.CodeGenTools to testing.BytecodeTesting
lrytz May 19, 2016
5d5a6aa
Better abstraction for bytecode tests. Also organize some imports.
lrytz May 20, 2016
d9ce4dc
Better abstraction for JUnit run tests
lrytz May 20, 2016
ba510ab
Clean up bytecode testing methods.
lrytz May 20, 2016
0e7964a
Small cleanup in JUnit test
lrytz May 20, 2016
46d523b
Cleanup in BytecodeTest
lrytz May 20, 2016
2537027
Split RunTest and BytecodeTest into parts, put in matching packages.
lrytz May 20, 2016
64fdae8
All JUnit tests pass without bootstrap (when run in intellij, sbt)
lrytz May 20, 2016
e26835c
Adapt naming convention for collection.convert null safety test
lrytz May 20, 2016
1ea1916
Merge pull request #4819 from som-snytt/issue/7916-ScriptEngine-deferred
szeiger May 20, 2016
eeef260
SI-8044 Allow binding backquoted varid in patterns
som-snytt Jan 31, 2016
2eb1cc2
SI-8044 Test for quoted not-a-varid
som-snytt Jan 31, 2016
1e565d8
SI-8044 Allow any id in explicit pattern binding
som-snytt Mar 15, 2016
a79b9b7
Merge pull request #4988 from som-snytt/issue/backtick-bar
adriaanm May 21, 2016
2e40aa5
Merge pull request #5180 from lrytz/junit-pass
retronym May 23, 2016
093c934
SI-9776: Fix type of PriorityQueue.newBuilder and improve performance
chrisokasaki May 23, 2016
95f5760
Merge pull request #5168 from xuwei-k/range-value-class
lrytz May 23, 2016
03d2de2
SI-9121 test case (fixed in new optimizer), SI-9179 test case
lrytz Apr 25, 2016
8e92ba0
Merge pull request #5153 from petermz/ticket/5463
lrytz May 23, 2016
82d9551
Merge pull request #5162 from milessabin/t9361
lrytz May 23, 2016
7645c7f
Merge pull request #5122 from lrytz/t9121
szeiger May 23, 2016
90ca3fd
Group Console and AnsiColor entities and add usage examples
janekdb May 23, 2016
d169d48
Merge pull request #5173 from janekdb/topic/2.12.x-scaladoc-AnsiColour
lrytz May 23, 2016
095295a
Merge pull request #5164 from viktorklang/wip-future-docs-√
adriaanm May 23, 2016
755fff0
Merge pull request #5181 from chrisokasaki/issue/9776
adriaanm May 23, 2016
0659af2
Merge pull request #5106 from milessabin/topic/hkgadt
adriaanm May 24, 2016
207e32d
Merge pull request #5179 from liff/topic/SI-9781
adriaanm May 24, 2016
892a6d6
SI-2712 Add support for higher order unification
milessabin May 20, 2016
bf47808
-Xexperimental mode now only includes -Ypartial-unification
milessabin May 20, 2016
4d28084
Merge pull request #5175 from som-snytt/issue/9656-range-toString
szeiger May 24, 2016
60f28f9
SI-9522 release key reference when deleting from OpenHashMap
performantdata Apr 25, 2016
808f3d0
Merge pull request #4935 from som-snytt/issue/8044-tickvar
adriaanm May 24, 2016
dd3a90e
Fix Scaladoc link syntax on java.util.Formatter references
janekdb May 24, 2016
1db58b5
Debug flag to print a summary of the inliner's work
lrytz May 24, 2016
c17ef77
Merge pull request #5124 from performantdata/bug/SI-9522
lrytz May 25, 2016
eaefb10
Merge pull request #5185 from janekdb/topic/2.12.x-scaladoc-java-link…
lrytz May 25, 2016
734c5ad
Merge pull request #5052 from kilotaras/topic/map-applyOrElse
lrytz May 25, 2016
450df0e
Use full braces style in AnsiColor example
janekdb May 25, 2016
65642d9
Merge pull request #5188 from janekdb/topic/2.12.x-scaladoc-AnsiColour-2
lrytz May 25, 2016
b85c9a7
Rename -Yopt to -opt, -Yopt-warnings to -opt-warnings
lrytz May 25, 2016
54dff81
SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
som-snytt May 25, 2016
3873fcf
Fully qualify types in REPL generated code
dwijnand May 24, 2016
edbf2c4
Merge pull request #5189 from lrytz/y-not
adriaanm May 26, 2016
0b79f4b
SI-9382 Zippy clean-up in aisle 2 & 3
som-snytt May 26, 2016
fd6386a
SI-9794 Error advice uses decoded method name
som-snytt May 27, 2016
a09ed48
Merge pull request #5192 from dwijnand/wip/scala-repl-no-imports
retronym May 27, 2016
79ec0f3
Merge pull request #5186 from lrytz/inlinerM5
retronym May 27, 2016
6b2037a
Merge pull request #5102 from milessabin/2.12.x
retronym May 27, 2016
981e3c5
SI-9483 Add `since` to `@deprecatedName`
soc Apr 2, 2016
673350e
SI-9084 Add `since` (if available) to deprecation warnings
soc Apr 2, 2016
5562e1a
Lower-case spelling of @deprecated messages
soc May 19, 2016
be38ebb
Add since arg to deprecationWarning and use it
soc Apr 2, 2016
85057d5
Add documentation to @deprecated
soc May 19, 2016
a45509c
Don't pass -opt to starr / locker build in the bootstrap script
lrytz May 30, 2016
6265eb8
Merge pull request #5200 from lrytz/bootstrap-opt-options
lrytz May 30, 2016
7d5a0b3
Merge pull request #5193 from som-snytt/issue/9794
lrytz May 30, 2016
9edbe3d
Merge pull request #5191 from som-snytt/issue/9382
lrytz May 30, 2016
8f567bc
Merge pull request #5076 from soc/topic/deprecations-since
lrytz May 30, 2016
7b132f3
Avoid tree sharing with substituteThis
retronym May 31, 2016
0533a3d
Lambda impl methods static and more stably named
retronym May 4, 2016
f01d061
Treat self parameter as non-null in the optimizer
lrytz May 13, 2016
7a589e0
Remove nonsensical body for trait getter
retronym May 19, 2016
b33e4a0
Better diagnostic for optimizer crashes
retronym May 9, 2016
f882d16
Remove stray .class file from version control
retronym May 31, 2016
c61795a
Don't minimize parents of java defined syms.
retronym May 31, 2016
4499c32
Revert pruning of redundant Java parents
retronym May 17, 2016
0cb67d1
clear all flags when resetting a symbol
lrytz May 25, 2016
e82e457
SI-9256 check companions in same compilation unit only if same run
lrytz May 25, 2016
e791790
Emit trait method bodies in statics
retronym May 4, 2016
3787426
Add impl restriction related to invokespecial to Java parents
retronym May 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bincompat-forward.whitelist.conf
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ filter {
{
matchName="scala.concurrent.impl.Promise$DefaultPromise"
problemName=MissingTypesProblem
},
{
matchName="scala.reflect.runtime.Settings.YpartialUnification"
problemName=MissingMethodProblem
}
]
}
2 changes: 1 addition & 1 deletion project/ScalaOptionParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ object ScalaOptionParser {
"-Yeta-expand-keeps-star", "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name",
"-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
"-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef",
"-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug",
"-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypartial-unification", "-Ypos-debug", "-Ypresentation-debug",
"-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based",
"-Yrepl-sync", "-Yshow-member-pos", "-Yshow-symkinds", "-Yshow-symowners", "-Yshow-syms", "-Yshow-trees", "-Yshow-trees-compact", "-Yshow-trees-stringified", "-Ytyper-debug",
"-Ywarn-adapted-args", "-Ywarn-dead-code", "-Ywarn-inaccessible", "-Ywarn-infer-any", "-Ywarn-nullary-override", "-Ywarn-nullary-unit", "-Ywarn-numeric-widen", "-Ywarn-unused", "-Ywarn-unused-import", "-Ywarn-value-discard",
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ trait ScalaSettings extends AbsScalaSettings
protected def defaultClasspath = sys.env.getOrElse("CLASSPATH", ".")

/** Enabled under -Xexperimental. */
protected def experimentalSettings = List[BooleanSetting](YmethodInfer, overrideObjects, overrideVars)
protected def experimentalSettings = List[BooleanSetting](YpartialUnification)

/** Enabled under -Xfuture. */
protected def futureSettings = List[BooleanSetting]()
Expand Down Expand Up @@ -201,6 +201,7 @@ trait ScalaSettings extends AbsScalaSettings
val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.").withDeprecationMessage(removalIn212)
val inferByName = BooleanSetting ("-Yinfer-by-name", "Allow inference of by-name types. This is a temporary option to ease transition. See SI-7899.").withDeprecationMessage(removalIn212)
val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
val YpartialUnification = BooleanSetting ("-Ypartial-unification", "Enable partial unification in type constructor inference")

val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method")
Expand Down
40 changes: 35 additions & 5 deletions src/reflect/scala/reflect/internal/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3131,13 +3131,43 @@ trait Types
*/
def unifyFull(tpe: Type): Boolean = {
def unifySpecific(tp: Type) = {
sameLength(typeArgs, tp.typeArgs) && {
val lhs = if (isLowerBound) tp.typeArgs else typeArgs
val rhs = if (isLowerBound) typeArgs else tp.typeArgs
val tpTypeArgs = tp.typeArgs
val arityDelta = compareLengths(typeArgs, tpTypeArgs)
if (arityDelta == 0) {
val lhs = if (isLowerBound) tpTypeArgs else typeArgs
val rhs = if (isLowerBound) typeArgs else tpTypeArgs
// This is a higher-kinded type var with same arity as tp.
// If so (see SI-7517), side effect: adds the type constructor itself as a bound.
isSubArgs(lhs, rhs, params, AnyDepth) && { addBound(tp.typeConstructor); true }
}
isSubArgs(lhs, rhs, params, AnyDepth) && {addBound(tp.typeConstructor); true}
} else if (settings.YpartialUnification && arityDelta < 0 && typeArgs.nonEmpty) {
// Simple algorithm as suggested by Paul Chiusano in the comments on SI-2712
//
// https://issues.scala-lang.org/browse/SI-2712?focusedCommentId=61270
//
// Treat the type constructor as curried and partially applied, we treat a prefix
// as constants and solve for the suffix. For the example in the ticket, unifying
// M[A] with Int => Int this unifies as,
//
// M[t] = [t][Int => t] --> abstract on the right to match the expected arity
// A = Int --> capture the remainder on the left
//
// A more "natural" unifier might be M[t] = [t][t => t]. There's lots of scope for
// experimenting with alternatives here.
val numCaptured = tpTypeArgs.length - typeArgs.length
val (captured, abstractedArgs) = tpTypeArgs.splitAt(numCaptured)

val (lhs, rhs) =
if (isLowerBound) (abstractedArgs, typeArgs)
else (typeArgs, abstractedArgs)

isSubArgs(lhs, rhs, params, AnyDepth) && {
val tpSym = tp.typeSymbolDirect
val abstractedTypeParams = tpSym.typeParams.drop(numCaptured).map(_.cloneSymbol(tpSym))

addBound(PolyType(abstractedTypeParams, appliedType(tp.typeConstructor, captured ++ abstractedTypeParams.map(_.tpeHK))))
true
}
} else false
}
// The type with which we can successfully unify can be hidden
// behind singleton types and type aliases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class MutableSettings extends AbsSettings {
def printtypes: BooleanSetting
def uniqid: BooleanSetting
def verbose: BooleanSetting
def YpartialUnification: BooleanSetting

def Yrecursion: IntSetting
def maxClassfileName: IntSetting
Expand Down
1 change: 1 addition & 0 deletions src/reflect/scala/reflect/runtime/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private[reflect] class Settings extends MutableSettings {
val printtypes = new BooleanSetting(false)
val uniqid = new BooleanSetting(false)
val verbose = new BooleanSetting(false)
val YpartialUnification = new BooleanSetting(false)

val Yrecursion = new IntSetting(0)
val maxClassfileName = new IntSetting(255)
Expand Down
13 changes: 13 additions & 0 deletions test/files/neg/t2712-1.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
t2712-1.scala:7: error: no type parameters for method foo: (m: M[A])Unit exist so that it can be applied to arguments (test.Two[Int,String])
--- because ---
argument expression's type is not compatible with formal parameter type;
found : test.Two[Int,String]
required: ?M[?A]
def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
^
t2712-1.scala:7: error: type mismatch;
found : test.Two[Int,String]
required: M[A]
def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
^
two errors found
8 changes: 8 additions & 0 deletions test/files/neg/t2712-1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test

trait Two[A, B]

object Test {
def foo[M[_], A](m: M[A]) = ()
def test(ma: Two[Int, String]) = foo(ma) // should fail with -Ypartial-unification *disabled*
}
13 changes: 13 additions & 0 deletions test/files/neg/t2712-2.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
t2712-2.scala:16: error: type mismatch;
found : test.Foo
required: test.Two[test.X1,Object]
Note: test.X2 <: Object (and test.Foo <: test.Two[test.X1,test.X2]), but trait Two is invariant in type B.
You may wish to define B as +B instead. (SLS 4.5)
test1(foo): One[X3] // fails with -Ypartial-unification enabled
^
t2712-2.scala:16: error: type mismatch;
found : test.Two[test.X1,Object]
required: test.One[test.X3]
test1(foo): One[X3] // fails with -Ypartial-unification enabled
^
two errors found
1 change: 1 addition & 0 deletions test/files/neg/t2712-2.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
18 changes: 18 additions & 0 deletions test/files/neg/t2712-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package test

class X1
class X2
class X3

trait One[A]
trait Two[A, B]

class Foo extends Two[X1, X2] with One[X3]
object Test {
def test1[M[_], A](x: M[A]): M[A] = x

val foo = new Foo

test1(foo): One[X3] // fails with -Ypartial-unification enabled
test1(foo): Two[X1, X2] // fails without -Ypartial-unification
}
6 changes: 6 additions & 0 deletions test/files/neg/t2712-3.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
t2712-3.scala:17: error: type mismatch;
found : test.One[test.X3]
required: test.Two[test.X1,test.X2]
test1(foo): Two[X1, X2] // fails without -Ypartial-unification
^
one error found
18 changes: 18 additions & 0 deletions test/files/neg/t2712-3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package test

class X1
class X2
class X3

trait One[A]
trait Two[A, B]

class Foo extends Two[X1, X2] with One[X3]
object Test {
def test1[M[_], A](x: M[A]): M[A] = x

val foo = new Foo

test1(foo): One[X3] // fails with -Ypartial-unification enabled
test1(foo): Two[X1, X2] // fails without -Ypartial-unification
}
1 change: 1 addition & 0 deletions test/files/neg/t2712.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
1 change: 1 addition & 0 deletions test/files/pos/t2712-1.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
9 changes: 9 additions & 0 deletions test/files/pos/t2712-1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package test

// Original test case from,
//
// https://issues.scala-lang.org/browse/SI-2712
object Test {
def meh[M[_], A](x: M[A]): M[A] = x
meh{(x: Int) => x} // solves ?M = [X] Int => X and ?A = Int ...
}
2 changes: 2 additions & 0 deletions test/files/pos/t2712-2.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Ypartial-unification

25 changes: 25 additions & 0 deletions test/files/pos/t2712-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package test

// See: https://github.com/milessabin/si2712fix-demo/issues/3
object Test {
trait A[T1, T2] { }
trait B[T1, T2] { }
class C[T] extends A[T, Long] with B[T, Double]
class CB extends A[Boolean, Long] with B[Boolean, Double]

trait A2[T]
trait B2[T]
class C2[T] extends A2[T] with B2[T]
class CB2 extends A2[Boolean] with B2[Boolean]

def meh[M[_], A](x: M[A]): M[A] = x

val m0 = meh(new C[Boolean])
m0: C[Boolean]
val m1 = meh(new CB)
m1: A[Boolean, Long]
val m2 = meh(new C2[Boolean])
m2: C2[Boolean]
val m3 = meh(new CB2)
m3: A2[Boolean]
}
2 changes: 2 additions & 0 deletions test/files/pos/t2712-3.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Ypartial-unification

24 changes: 24 additions & 0 deletions test/files/pos/t2712-3.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package test

object Test1 {
class Foo[T, F[_]]
def meh[M[_[_]], F[_]](x: M[F]): M[F] = x
meh(new Foo[Int, List]) // solves ?M = [X[_]]Foo[Int, X[_]] ?A = List ...
}

object Test2 {
trait TC[T]
class Foo[F[_], G[_]]
def meh[G[_[_]]](g: G[TC]) = ???
meh(new Foo[TC, TC]) // solves ?G = [X[_]]Foo[TC, X]
}

object Test3 {
trait TC[F[_]]
trait TC2[F[_]]
class Foo[F[_[_]], G[_[_]]]
new Foo[TC, TC2]

def meh[G[_[_[_]]]](g: G[TC2]) = ???
meh(new Foo[TC, TC2]) // solves ?G = [X[_[_]]]Foo[TC, X]
}
2 changes: 2 additions & 0 deletions test/files/pos/t2712-4.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Ypartial-unification

17 changes: 17 additions & 0 deletions test/files/pos/t2712-4.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package test

object Test1 {
trait X
trait Y extends X
class Foo[T, U <: X]
def meh[M[_ <: A], A](x: M[A]): M[A] = x
meh(new Foo[Int, Y])
}

object Test2 {
trait X
trait Y extends X
class Foo[T, U >: Y]
def meh[M[_ >: A], A](x: M[A]): M[A] = x
meh(new Foo[Int, X])
}
1 change: 1 addition & 0 deletions test/files/pos/t2712-5.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
29 changes: 29 additions & 0 deletions test/files/pos/t2712-5.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package test

import scala.language.higherKinds

trait Functor[F[_]] {
def map[A, B](f: A => B, fa: F[A]): F[B]
}

object Functor {
implicit def function[A]: Functor[({ type l[B] = A => B })#l] =
new Functor[({ type l[B] = A => B })#l] {
def map[C, B](cb: C => B, ac: A => C): A => B = cb compose ac
}
}

object FunctorSyntax {
implicit class FunctorOps[F[_], A](fa: F[A])(implicit F: Functor[F]) {
def map[B](f: A => B): F[B] = F.map(f, fa)
}
}

object Test {

val f: Int => String = _.toString

import FunctorSyntax._

f.map((s: String) => s.reverse)
}
1 change: 1 addition & 0 deletions test/files/pos/t2712-6.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
12 changes: 12 additions & 0 deletions test/files/pos/t2712-6.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package test

object Tags {
type Tagged[A, T] = {type Tag = T; type Self = A}

type @@[T, Tag] = Tagged[T, Tag]

trait Disjunction

def meh[M[_], A](ma: M[A]): M[A] = ma
meh(null.asInstanceOf[Int @@ Disjunction])
}
1 change: 1 addition & 0 deletions test/files/pos/t2712-7.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
15 changes: 15 additions & 0 deletions test/files/pos/t2712-7.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package test

// Cats Xor, Scalaz \/, scala.util.Either
sealed abstract class Xor[+A, +B] extends Product with Serializable
object Xor {
final case class Left[+A](a: A) extends (A Xor Nothing)
final case class Right[+B](b: B) extends (Nothing Xor B)
}

object TestXor {
import Xor._
def meh[F[_], A, B](fa: F[A])(f: A => B): F[B] = ???
meh(new Right(23): Xor[Boolean, Int])(_ < 13)
meh(new Left(true): Xor[Boolean, Int])(_ < 13)
}
1 change: 1 addition & 0 deletions test/files/pos/t5683.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Ypartial-unification
23 changes: 23 additions & 0 deletions test/files/pos/t5683.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
object Test {
trait NT[X]
trait W[W, A] extends NT[Int]
type StringW[T] = W[String, T]
trait K[M[_], A, B]

def k[M[_], B](f: Int => M[B]): K[M, Int, B] = null

val okay1: K[StringW,Int,Int] = k{ (y: Int) => null: StringW[Int] }
val okay2 = k[StringW,Int]{ (y: Int) => null: W[String, Int] }

val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }

// remove `extends NT[Int]`, and the last line gives an inference error
// rather than a crash.
// test/files/pos/t5683.scala:12: error: no type parameters for method k: (f: Int => M[B])Test.K[M,Int,B] exist so that it can be applied to arguments (Int => Test.W[String,Int])
// --- because ---
// argument expression's type is not compatible with formal parameter type;
// found : Int => Test.W[String,Int]
// required: Int => ?M[?B]
// val crash: K[StringW,Int,Int] = k{ (y: Int) => null: W[String, Int] }
// ^
}
2 changes: 2 additions & 0 deletions test/files/pos/t6895b.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Ypartial-unification

Loading