From d4e2058a3a8d49e4b130223ecaf45036f5d9096d Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Fri, 6 Aug 2010 15:58:44 +0000 Subject: close #3403. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 8 +++++++- test/files/neg/t3403.check | 4 ++++ test/files/neg/t3403.scala | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/files/neg/t3403.check create mode 100644 test/files/neg/t3403.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 770daccef0..ddbba00653 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1398,10 +1398,16 @@ trait Typers { self: Analyzer => (if (value.hasAnnotation(BooleanBeanPropertyAttr)) "is" else "get") + nameSuffix val beanGetter = value.owner.info.decl(beanGetterName) + if (beanGetter == NoSymbol) { + // the namer decides wether to generate these symbols or not. at that point, we don't + // have symbolic information yet, so we only look for annotations named "BeanProperty". + unit.error(stat.pos, "implementation limitation: the BeanProperty annotation cannot be used in a type alias or renamed import") + } beanGetter.setAnnotations(memberAnnots(allAnnots, BeanGetterTargetClass)) - if (mods hasFlag MUTABLE) { + if (mods.hasFlag(MUTABLE) && beanGetter != NoSymbol) { val beanSetterName = "set" + nameSuffix val beanSetter = value.owner.info.decl(beanSetterName) + // unlike for the beanGetter, the beanSetter body is generated here. see comment in Namers. gs.append(setterDef(beanSetter, isBean = true)) } } diff --git a/test/files/neg/t3403.check b/test/files/neg/t3403.check new file mode 100644 index 0000000000..e52d140e6a --- /dev/null +++ b/test/files/neg/t3403.check @@ -0,0 +1,4 @@ +t3403.scala:2: error: implementation limitation: the BeanProperty annotation cannot be used in a type alias or renamed import +class Foo { @bp var bar: Int = 1 } + ^ +one error found diff --git a/test/files/neg/t3403.scala b/test/files/neg/t3403.scala new file mode 100644 index 0000000000..8be6ab2a31 --- /dev/null +++ b/test/files/neg/t3403.scala @@ -0,0 +1,2 @@ +import scala.reflect.{BeanProperty => bp} +class Foo { @bp var bar: Int = 1 } -- cgit v1.2.3