summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-02-19 18:02:44 +0100
committerMartin Odersky <odersky@gmail.com>2012-02-19 18:03:19 +0100
commit64aaef72504b46b9d40359eb0476ad8416f36023 (patch)
treecb41068323ee789847e287a9caf6695856580f16 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent8cc7de74d35b437b7126d02a6219796b5872ac14 (diff)
downloadscala-64aaef72504b46b9d40359eb0476ad8416f36023.tar.gz
scala-64aaef72504b46b9d40359eb0476ad8416f36023.tar.bz2
scala-64aaef72504b46b9d40359eb0476ad8416f36023.zip
Implemented super access in value classes, restrictions for value classes.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 008a2e1764..fde9b6f551 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1205,13 +1205,19 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
sym == acc || acc.hasAccessorFlag && sym == acc.accessed
if (acc.accessBoundary(clazz) != RootClass)
unit.error(acc.pos, "Value class needs to have a publicly accessible val parameter")
- else
- for (stat <- body)
- if (!treeInfo.isAllowedInUniversalTrait(stat) && !isUnderlyingAcc(stat.symbol))
- unit.error(stat.pos, "This statement is not allowed in value class: "+stat)
+ if (acc.tpe.resultType.typeSymbol.isTypeParameter)
+ unit.error(acc.pos, "Type of parameter of value class may not be a type variable")
+ for (stat <- body)
+ if (!treeInfo.isAllowedInUniversalTrait(stat) && !isUnderlyingAcc(stat.symbol))
+ unit.error(stat.pos,
+ if (stat.symbol hasFlag PARAMACCESSOR) "Illegal parameter for value class"
+ else "This statement is not allowed in value class: "+stat)
case x =>
unit.error(clazz.pos, "Value class needs to have exactly one public val parameter")
}
+ for (tparam <- clazz.typeParams)
+ if (tparam hasAnnotation definitions.SpecializedClass)
+ unit.error(tparam.pos, "type parameter of value class may not be specialized")
}
def parentTypes(templ: Template): List[Tree] =
@@ -1437,10 +1443,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
_.typedTemplate(cdef.impl, parentTypes(cdef.impl))
}
val impl2 = finishMethodSynthesis(impl1, clazz, context)
- if (clazz.isTrait && clazz.info.parents.nonEmpty && clazz.info.firstParent.typeSymbol == AnyClass)
+ if (clazz.isTrait && clazz.info.parents.nonEmpty && clazz.info.firstParent.normalize.typeSymbol == AnyClass)
for (stat <- impl2.body)
if (!treeInfo.isAllowedInUniversalTrait(stat))
- unit.error(stat.pos, "this statement is not allowed in trait extending from class Any: "+stat)
+ unit.error(stat.pos, "this statement is not allowed in universal trait extending from class Any: "+stat)
if ((clazz != ClassfileAnnotationClass) &&
(clazz isNonBottomSubClass ClassfileAnnotationClass))
restrictionWarning(cdef.pos, unit,