Skip to content

Commit 192d65f

Browse files
committed
Merge pull request scala#4021 from retronym/ticket/8869
SI-8869 Prevent ill-kindedness in type lambdas
2 parents 955256f + 84d4671 commit 192d65f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ trait Contexts { self: Analyzer =>
480480
// SI-8245 `isLazy` need to skip lazy getters to ensure `return` binds to the right place
481481
c.enclMethod = if (isDefDef && !owner.isLazy) c else enclMethod
482482

483+
if (tree != outer.tree) c(TypeConstructorAllowed) = false
484+
483485
registerContext(c.asInstanceOf[analyzer.Context])
484486
debuglog("[context] ++ " + c.unit + " / " + tree.summaryString)
485487
c

test/files/neg/t8869.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
t8869.scala:5: error: class Option takes type parameters
2+
def value: TC[({type l1[x] = Option})#l1] = ??? // error not reported!
3+
^
4+
t8869.scala:7: error: class Option takes type parameters
5+
type l2[x] = Option // error correctly reported
6+
^
7+
two errors found

test/files/neg/t8869.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class TC[T[_]] {
2+
def identity[A](a: T[A]): T[A] = a
3+
}
4+
object Test {
5+
def value: TC[({type l1[x] = Option})#l1] = ??? // error not reported!
6+
7+
type l2[x] = Option // error correctly reported
8+
def value1: TC[l2] = ???
9+
}
10+

0 commit comments

Comments
 (0)