From 84d46719a9ab3caa7ff46af4630d75f8c407c3d2 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 1 Oct 2014 08:51:36 +1000 Subject: SI-8869 Prevent ill-kindedness in type lambdas When type checking an type application, the arguments are allowed to be of kinds other than *. This leniency is controlled by the `ContextMode` bit `TypeConstructorAllowed`. (More fine grained checking of matching arity a bounds of type constructors is deferred until the refchecks phase to avoid cycles during typechecking.) However, this bit is propagated to child contexts, which means that we fail to report this error in the lexical context marked here: T[({type x = Option}#x)] `-------------' This commit resets this bit to false in any child context relates to a different tree from its parent. --- test/files/neg/t8869.check | 7 +++++++ test/files/neg/t8869.scala | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/files/neg/t8869.check create mode 100644 test/files/neg/t8869.scala (limited to 'test/files') diff --git a/test/files/neg/t8869.check b/test/files/neg/t8869.check new file mode 100644 index 0000000000..40b8570f9f --- /dev/null +++ b/test/files/neg/t8869.check @@ -0,0 +1,7 @@ +t8869.scala:5: error: class Option takes type parameters + def value: TC[({type l1[x] = Option})#l1] = ??? // error not reported! + ^ +t8869.scala:7: error: class Option takes type parameters + type l2[x] = Option // error correctly reported + ^ +two errors found diff --git a/test/files/neg/t8869.scala b/test/files/neg/t8869.scala new file mode 100644 index 0000000000..0c7f0c9451 --- /dev/null +++ b/test/files/neg/t8869.scala @@ -0,0 +1,10 @@ +class TC[T[_]] { + def identity[A](a: T[A]): T[A] = a +} +object Test { + def value: TC[({type l1[x] = Option})#l1] = ??? // error not reported! + + type l2[x] = Option // error correctly reported + def value1: TC[l2] = ??? +} + -- cgit v1.2.3