Skip to content

Commit b9c89cc

Browse files
committed
Merge pull request scala#4117 from retronym/ticket/8449
SI-8449 Fix spurious error with Java raw type over a Scala class
2 parents ebf16c7 + 3a4d4db commit b9c89cc

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,13 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
870870

871871
def adaptType(): Tree = {
872872
// @M When not typing a type constructor (!context.inTypeConstructorAllowed)
873-
// or raw type (tree.symbol.isJavaDefined && context.unit.isJava), types must be of kind *,
873+
// or raw type, types must be of kind *,
874874
// and thus parameterized types must be applied to their type arguments
875875
// @M TODO: why do kind-* tree's have symbols, while higher-kinded ones don't?
876876
def properTypeRequired = (
877877
tree.hasSymbolField
878878
&& !context.inTypeConstructorAllowed
879-
&& !(tree.symbol.isJavaDefined && context.unit.isJava)
879+
&& !context.unit.isJava
880880
)
881881
// @M: don't check tree.tpe.symbol.typeParams. check tree.tpe.typeParams!!!
882882
// (e.g., m[Int] --> tree.tpe.symbol.typeParams.length == 1, tree.tpe.typeParams.length == 0!)

test/files/t8449/Client.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Client {
2+
def foo: Any = new Test().foo
3+
}

test/files/t8449/Test.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Test {
2+
// Raw type over a Scala type constructor
3+
public scala.Function1 foo() { return null; }
4+
// scalac reported:
5+
// % scalac-hash v2.11.2 -d /tmp sandbox/{Test.java,Client.scala}
6+
// sandbox/Test.java:2: error: trait Function1 takes type parameters
7+
// public scala.Function1 foo() { return null; }
8+
// ^
9+
// one error found
10+
}

0 commit comments

Comments
 (0)