diff options
author | Martin Odersky <odersky@gmail.com> | 2012-09-16 21:13:12 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-09-16 22:04:50 +0200 |
commit | 344215b92d22d2101067d6abd8172ac791a30f09 (patch) | |
tree | 67e9e6a90bc206d8706946ce964133d63c18eeaa /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 4d8d2e52361586f32a1a52b9a78728aca0d5bf0c (diff) | |
download | scala-344215b92d22d2101067d6abd8172ac791a30f09.tar.gz scala-344215b92d22d2101067d6abd8172ac791a30f09.tar.bz2 scala-344215b92d22d2101067d6abd8172ac791a30f09.zip |
SI-6336 Disallows value types in structuralal refinements
Structural refinements already have a number of restrictions, e.g. cannot refer to
type parameters of enclosing classes. We need to disallow value classes as well.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5200aae8d1..85f260f2b4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1984,18 +1984,21 @@ trait Typers extends Modes with Adaptations with Tags { case PolyType(_, restpe) => restpe case _ => NoType } - + def failStruct(what: String) = + fail(s"Parameter type in structural refinement may not refer to $what") for (paramType <- tp.paramTypes) { val sym = paramType.typeSymbol if (sym.isAbstractType) { if (!sym.hasTransOwner(meth.owner)) - fail("Parameter type in structural refinement may not refer to an abstract type defined outside that refinement") + failStruct("an abstract type defined outside that refinement") else if (!sym.hasTransOwner(meth)) - fail("Parameter type in structural refinement may not refer to a type member of that refinement") + failStruct("a type member of that refinement") } + if (sym.isDerivedValueClass) + failStruct("a user-defined value class") if (paramType.isInstanceOf[ThisType] && sym == meth.owner) - fail("Parameter type in structural refinement may not refer to the type of that refinement (self type)") + failStruct("the type of that refinement (self type)") } } def typedUseCase(useCase: UseCase) { |