diff --git a/build.xml b/build.xml index 6c750e530df5..c0432b4c8e77 100755 --- a/build.xml +++ b/build.xml @@ -732,11 +732,6 @@ TODO: - - - - - @@ -786,7 +781,6 @@ TODO: - @@ -820,10 +814,6 @@ TODO: - - - - @@ -871,7 +861,6 @@ TODO: - @@ -1108,11 +1097,6 @@ TODO: - - - - - @@ -1162,14 +1146,12 @@ TODO: --> - - - + @@ -1598,13 +1580,6 @@ TODO: --> - - - - - - - @@ -1613,7 +1588,7 @@ TODO: - + diff --git a/spec/11-user-defined-annotations.md b/spec/11-user-defined-annotations.md index fd7a7f9d3fd9..e33a997970ab 100644 --- a/spec/11-user-defined-annotations.md +++ b/spec/11-user-defined-annotations.md @@ -61,21 +61,6 @@ Java platform, the following annotations have a standard meaning. clause for the method or constructor must mention the class of that exception or one of the superclasses of the class of that exception. -## Java Beans Annotations - - * `@scala.beans.BeanProperty` When prefixed to a definition of some variable `X`, this - annotation causes getter and setter methods `getX`, `setX` - in the Java bean style to be added in the class containing the - variable. The first letter of the variable appears capitalized after - the `get` or `set`. When the annotation is added to the - definition of an immutable value definition `X`, only a getter is - generated. The construction of these methods is part of - code-generation; therefore, these methods become visible only once a - classfile for the containing class is generated. - - * `@scala.beans.BooleanBeanProperty` This annotation is equivalent to `scala.reflect.BeanProperty`, but - the generated getter method is named `isX` instead of `getX`. - ## Deprecation Annotations * `@deprecated()` Marks a definition as deprecated. Accesses to the diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 6c073c0b4c66..58879c39b23f 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -255,21 +255,6 @@ trait Reshape { stats collect { case ddef: DefDef => ddef } foreach (defdef => { val valdef = symdefs get defdef.symbol.accessedOrSelf collect { case vdef: ValDef => vdef } getOrElse null if (valdef != null) accessors(valdef) = accessors.getOrElse(valdef, Nil) :+ defdef - - def detectBeanAccessors(prefix: String): Unit = { - if (defdef.name.startsWith(prefix)) { - val name = defdef.name.toString.substring(prefix.length) - def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) } - def findValDef(name: String) = symdefs.values collectFirst { - case vdef: ValDef if vdef.name.dropLocal string_== name => vdef - } - val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull - if (valdef != null) accessors(valdef) = accessors.getOrElse(valdef, Nil) :+ defdef - } - } - detectBeanAccessors("get") - detectBeanAccessors("set") - detectBeanAccessors("is") }) val stats1 = stats flatMap { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index 5670715cd3ba..ed495435ed2a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -782,7 +782,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters { } } // end of trait BCClassGen - /* basic functionality for class file building of plain, mirror, and beaninfo classes. */ + /* basic functionality for class file building of plain and mirror classes. */ abstract class JBuilder extends BCInnerClassGen { } // end of class JBuilder @@ -850,120 +850,6 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters { } // end of class JMirrorBuilder - /* builder of bean info classes */ - class JBeanInfoBuilder extends JBuilder { - - /* - * Generate a bean info class that describes the given class. - * - * @author Ross Judson (ross.judson@soletta.com) - * - * must-single-thread - */ - def genBeanInfoClass(cls: Symbol, cunit: CompilationUnit, fieldSymbols: List[Symbol], methodSymbols: List[Symbol]): asm.tree.ClassNode = { - - def javaSimpleName(s: Symbol): String = { s.javaSimpleName.toString } - - innerClassBufferASM.clear() - - val flags = javaFlags(cls) - - val beanInfoName = (internalName(cls) + "BeanInfo") - val beanInfoClass = new asm.tree.ClassNode - beanInfoClass.visit( - classfileVersion, - flags, - beanInfoName, - null, // no java-generic-signature - "scala/beans/ScalaBeanInfo", - EMPTY_STRING_ARRAY - ) - - beanInfoClass.visitSource( - cunit.source.toString, - null /* SourceDebugExtension */ - ) - - var fieldList = List[String]() - - for (f <- fieldSymbols if f.hasGetter; - g = f.getter(cls); - s = f.setter(cls); - if g.isPublic && !(f.name startsWith "$") - ) { - // inserting $outer breaks the bean - fieldList = javaSimpleName(f) :: javaSimpleName(g) :: (if (s != NoSymbol) javaSimpleName(s) else null) :: fieldList - } - - val methodList: List[String] = - for (m <- methodSymbols - if !m.isConstructor && - m.isPublic && - !(m.name startsWith "$") && - !m.isGetter && - !m.isSetter) - yield javaSimpleName(m) - - val constructor = beanInfoClass.visitMethod( - asm.Opcodes.ACC_PUBLIC, - INSTANCE_CONSTRUCTOR_NAME, - "()V", - null, // no java-generic-signature - EMPTY_STRING_ARRAY // no throwable exceptions - ) - - val stringArrayJType: BType = ArrayBType(StringReference) - val conJType: BType = MethodBType( - classBTypeFromSymbol(definitions.ClassClass) :: stringArrayJType :: stringArrayJType :: Nil, - UNIT - ) - - def push(lst: List[String]) { - var fi = 0 - for (f <- lst) { - constructor.visitInsn(asm.Opcodes.DUP) - constructor.visitLdcInsn(new java.lang.Integer(fi)) - if (f == null) { constructor.visitInsn(asm.Opcodes.ACONST_NULL) } - else { constructor.visitLdcInsn(f) } - constructor.visitInsn(StringReference.typedOpcode(asm.Opcodes.IASTORE)) - fi += 1 - } - } - - constructor.visitCode() - - constructor.visitVarInsn(asm.Opcodes.ALOAD, 0) - // push the class - constructor.visitLdcInsn(classBTypeFromSymbol(cls).toASMType) - - // push the string array of field information - constructor.visitLdcInsn(new java.lang.Integer(fieldList.length)) - constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, StringReference.internalName) - push(fieldList) - - // push the string array of method information - constructor.visitLdcInsn(new java.lang.Integer(methodList.length)) - constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, StringReference.internalName) - push(methodList) - - // invoke the superclass constructor, which will do the - // necessary java reflection and create Method objects. - constructor.visitMethodInsn(asm.Opcodes.INVOKESPECIAL, "scala/beans/ScalaBeanInfo", INSTANCE_CONSTRUCTOR_NAME, conJType.descriptor, false) - constructor.visitInsn(asm.Opcodes.RETURN) - - constructor.visitMaxs(0, 0) // just to follow protocol, dummy arguments - constructor.visitEnd() - - innerClassBufferASM ++= classBTypeFromSymbol(cls).info.memberClasses - addInnerClassesASM(beanInfoClass, innerClassBufferASM.toList) - - beanInfoClass.visitEnd() - - beanInfoClass - } - - } // end of class JBeanInfoBuilder - trait JAndroidBuilder { self: BCInnerClassGen => diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 7bf61b4f513a..0e02beb0ea16 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -562,7 +562,7 @@ abstract class BTypes { * Mirror Classes * -------------- * - * TODO: innerclass attributes on mirror class, bean info class + * TODO: innerclass attributes on mirror class class */ /** diff --git a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala index fac3c93be2d2..c771302b5cde 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala @@ -130,8 +130,6 @@ class CoreBTypes[BTFS <: BTypesFromSymbols[_ <: Global]](val bTypes: BTFS) { lazy val AndroidParcelableInterface : Symbol = getClassIfDefined("android.os.Parcelable") lazy val AndroidCreatorClass : Symbol = getClassIfDefined("android.os.Parcelable$Creator") - lazy val BeanInfoAttr: Symbol = requiredClass[scala.beans.BeanInfo] - /* The Object => String overload. */ lazy val String_valueOf: Symbol = { getMember(StringModule, nme.valueOf) filter (sym => sym.info.paramTypes match { @@ -273,8 +271,6 @@ final class CoreBTypesProxy[BTFS <: BTypesFromSymbols[_ <: Global]](val bTypes: def AndroidParcelableInterface : Symbol = _coreBTypes.AndroidParcelableInterface def AndroidCreatorClass : Symbol = _coreBTypes.AndroidCreatorClass - def BeanInfoAttr: Symbol = _coreBTypes.BeanInfoAttr - def String_valueOf: Symbol = _coreBTypes.String_valueOf def FunctionReference : Vector[ClassBType] = _coreBTypes.FunctionReference diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 2593903b9de6..1708228d36a8 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -71,10 +71,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { binarynme.RuntimeNull.toString() -> RuntimeNullClass ) - // Lazy val; can't have eager vals in Phase constructors which may - // cause cycles before Global has finished initialization. - lazy val BeanInfoAttr = rootMirror.getRequiredClass("scala.beans.BeanInfo") - private def initBytecodeWriter(entryPoints: List[IClass]): BytecodeWriter = { settings.outputDirs.getSingleOutput match { case Some(f) if f hasExtension "jar" => @@ -126,7 +122,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { val needsOutfile = bytecodeWriter.isInstanceOf[ClassBytecodeWriter] val plainCodeGen = new JPlainBuilder( bytecodeWriter, needsOutfile) val mirrorCodeGen = new JMirrorBuilder( bytecodeWriter, needsOutfile) - val beanInfoCodeGen = new JBeanInfoBuilder(bytecodeWriter, needsOutfile) def emitFor(c: IClass) { if (isStaticModule(c.symbol) && isTopLevelModule(c.symbol)) { @@ -136,7 +131,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { log(s"No mirror class for module with linked class: ${c.symbol.fullName}") } plainCodeGen genClass c - if (c.symbol hasAnnotation BeanInfoAttr) beanInfoCodeGen genBeanInfoClass c } while (!sortedClasses.isEmpty) { @@ -462,7 +456,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } // ----------------------------------------------------------------------------------------- - // utilities useful when emitting plain, mirror, and beaninfo classes. + // utilities useful when emitting plain, mirror classes. // ----------------------------------------------------------------------------------------- def writeIfNotTooBig(label: String, jclassName: String, jclass: asm.ClassWriter, sym: Symbol) { @@ -2786,134 +2780,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { } } // end of class JMirrorBuilder - - /** builder of bean info classes */ - class JBeanInfoBuilder(bytecodeWriter: BytecodeWriter, needsOutfile: Boolean) extends JBuilder(bytecodeWriter, needsOutfile) { - - /** - * Generate a bean info class that describes the given class. - * - * @author Ross Judson (ross.judson@soletta.com) - */ - def genBeanInfoClass(clasz: IClass) { - - // val BeanInfoSkipAttr = definitions.getRequiredClass("scala.beans.BeanInfoSkip") - // val BeanDisplayNameAttr = definitions.getRequiredClass("scala.beans.BeanDisplayName") - // val BeanDescriptionAttr = definitions.getRequiredClass("scala.beans.BeanDescription") - // val description = c.symbol getAnnotation BeanDescriptionAttr - // informProgress(description.toString) - innerClassBuffer.clear() - - val flags = mkFlags( - javaFlags(clasz.symbol), - if(isDeprecated(clasz.symbol)) asm.Opcodes.ACC_DEPRECATED else 0 // ASM pseudo access flag - ) - - val beanInfoName = (javaName(clasz.symbol) + "BeanInfo") - val beanInfoClass = createJClass( - flags, - beanInfoName, - null, // no java-generic-signature - "scala/beans/ScalaBeanInfo", - EMPTY_STRING_ARRAY - ) - - // beanInfoClass typestate: entering mode with valid call sequences: - // [ visitSource ] [ visitOuterClass ] ( visitAnnotation | visitAttribute )* - - beanInfoClass.visitSource( - clasz.cunit.source.toString, - null /* SourceDebugExtension */ - ) - - var fieldList = List[String]() - - for (f <- clasz.fields if f.symbol.hasGetter; - g = f.symbol.getter(clasz.symbol); - s = f.symbol.setter(clasz.symbol) - if g.isPublic && !(f.symbol.name startsWith "$") - ) { - // inserting $outer breaks the bean - fieldList = javaName(f.symbol) :: javaName(g) :: (if (s != NoSymbol) javaName(s) else null) :: fieldList - } - - val methodList: List[String] = - for (m <- clasz.methods - if !m.symbol.isConstructor && - m.symbol.isPublic && - !(m.symbol.name startsWith "$") && - !m.symbol.isGetter && - !m.symbol.isSetter) - yield javaName(m.symbol) - - // beanInfoClass typestate: entering mode with valid call sequences: - // ( visitInnerClass | visitField | visitMethod )* visitEnd - - val constructor = beanInfoClass.visitMethod( - asm.Opcodes.ACC_PUBLIC, - INSTANCE_CONSTRUCTOR_NAME, - mdesc_arglessvoid, - null, // no java-generic-signature - EMPTY_STRING_ARRAY // no throwable exceptions - ) - - // constructor typestate: entering mode with valid call sequences: - // [ visitAnnotationDefault ] ( visitAnnotation | visitParameterAnnotation | visitAttribute )* - - val stringArrayJType: asm.Type = javaArrayType(JAVA_LANG_STRING) - val conJType: asm.Type = - asm.Type.getMethodType( - asm.Type.VOID_TYPE, - Array(javaType(ClassClass), stringArrayJType, stringArrayJType): _* - ) - - def push(lst: List[String]) { - var fi = 0 - for (f <- lst) { - constructor.visitInsn(asm.Opcodes.DUP) - constructor.visitLdcInsn(new java.lang.Integer(fi)) - if (f == null) { constructor.visitInsn(asm.Opcodes.ACONST_NULL) } - else { constructor.visitLdcInsn(f) } - constructor.visitInsn(JAVA_LANG_STRING.getOpcode(asm.Opcodes.IASTORE)) - fi += 1 - } - } - - // constructor typestate: entering mode with valid call sequences: - // [ visitCode ( visitFrame | visitXInsn | visitLabel | visitTryCatchBlock | visitLocalVariable | visitLineNumber )* visitMaxs ] visitEnd - - constructor.visitCode() - - constructor.visitVarInsn(asm.Opcodes.ALOAD, 0) - // push the class - constructor.visitLdcInsn(javaType(clasz.symbol)) - - // push the string array of field information - constructor.visitLdcInsn(new java.lang.Integer(fieldList.length)) - constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, JAVA_LANG_STRING.getInternalName) - push(fieldList) - - // push the string array of method information - constructor.visitLdcInsn(new java.lang.Integer(methodList.length)) - constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, JAVA_LANG_STRING.getInternalName) - push(methodList) - - // invoke the superclass constructor, which will do the - // necessary java reflection and create Method objects. - constructor.visitMethodInsn(asm.Opcodes.INVOKESPECIAL, "scala/beans/ScalaBeanInfo", INSTANCE_CONSTRUCTOR_NAME, conJType.getDescriptor, false) - constructor.visitInsn(asm.Opcodes.RETURN) - - constructor.visitMaxs(0, 0) // just to follow protocol, dummy arguments - constructor.visitEnd() - - addInnerClasses(clasz.symbol, beanInfoClass) - beanInfoClass.visitEnd() - - writeIfNotTooBig("BeanInfo ", beanInfoName, beanInfoClass, clasz.symbol) - } - - } // end of class JBeanInfoBuilder - /** A namespace for utilities to normalize the code of an IMethod, over and beyond what IMethod.normalize() strives for. * In particualr, IMethod.normalize() doesn't collapseJumpChains(). * diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala index 0a7c894a6911..a544ff4a513f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala @@ -31,13 +31,12 @@ import scala.tools.asm * (2) The second queue contains items where a ClassDef has been lowered into: * (a) an optional mirror class, * (b) a plain class, and - * (c) an optional bean class. * * (3) The third queue contains items ready for serialization. * It's a priority queue that follows the original arrival order, * so as to emit identical jars on repeated compilation of the same sources. * - * Plain, mirror, and bean classes are built respectively by PlainClassBuilder, JMirrorBuilder, and JBeanInfoBuilder. + * Plain, mirror classes are built respectively by PlainClassBuilder, JMirrorBuilder. * * @author Miguel Garcia, http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/ * @version 1.0 @@ -63,7 +62,6 @@ abstract class GenBCode extends BCodeSyncAndTry { private var bytecodeWriter : BytecodeWriter = null private var mirrorCodeGen : JMirrorBuilder = null - private var beanInfoCodeGen : JBeanInfoBuilder = null /* ---------------- q1 ---------------- */ @@ -78,19 +76,18 @@ abstract class GenBCode extends BCodeSyncAndTry { case class Item2(arrivalPos: Int, mirror: asm.tree.ClassNode, plain: asm.tree.ClassNode, - bean: asm.tree.ClassNode, outFolder: scala.tools.nsc.io.AbstractFile) { def isPoison = { arrivalPos == Int.MaxValue } } - private val poison2 = Item2(Int.MaxValue, null, null, null, null) + private val poison2 = Item2(Int.MaxValue, null, null, null) private val q2 = new _root_.java.util.LinkedList[Item2] /* ---------------- q3 ---------------- */ /* * An item of queue-3 (the last queue before serializing to disk) contains three of these - * (one for each of mirror, plain, and bean classes). + * (one for each of mirror, plain classes). * * @param jclassName internal name of the class * @param jclassBytes bytecode emitted for the class SubItem3 represents @@ -103,7 +100,6 @@ abstract class GenBCode extends BCodeSyncAndTry { case class Item3(arrivalPos: Int, mirror: SubItem3, plain: SubItem3, - bean: SubItem3, outFolder: scala.tools.nsc.io.AbstractFile) { def isPoison = { arrivalPos == Int.MaxValue } @@ -115,7 +111,7 @@ abstract class GenBCode extends BCodeSyncAndTry { else 1 } } - private val poison3 = Item3(Int.MaxValue, null, null, null, null) + private val poison3 = Item3(Int.MaxValue, null, null, null) private val q3 = new java.util.PriorityQueue[Item3](1000, i3comparator) /* @@ -145,7 +141,7 @@ abstract class GenBCode extends BCodeSyncAndTry { /* * Checks for duplicate internal names case-insensitively, - * builds ASM ClassNodes for mirror, plain, and bean classes; + * builds ASM ClassNodes for mirror, plain classes; * enqueues them in queue-2. * */ @@ -183,21 +179,11 @@ abstract class GenBCode extends BCodeSyncAndTry { val outF = if (needsOutFolder) getOutFolder(claszSymbol, pcb.thisName, cunit) else null; val plainC = pcb.cnode - // -------------- bean info class, if needed -------------- - val beanC = - if (claszSymbol hasAnnotation BeanInfoAttr) { - beanInfoCodeGen.genBeanInfoClass( - claszSymbol, cunit, - fieldSymbols(claszSymbol), - methodSymbols(cd) - ) - } else null - // ----------- hand over to pipeline-2 val item2 = Item2(arrivalPos, - mirrorC, plainC, beanC, + mirrorC, plainC, outF) q2 add item2 // at the very end of this method so that no Worker2 thread starts mutating before we're done. @@ -240,19 +226,17 @@ abstract class GenBCode extends BCodeSyncAndTry { cw.toByteArray } - val Item2(arrivalPos, mirror, plain, bean, outFolder) = item + val Item2(arrivalPos, mirror, plain, outFolder) = item val mirrorC = if (mirror == null) null else SubItem3(mirror.name, getByteArray(mirror)) val plainC = SubItem3(plain.name, getByteArray(plain)) - val beanC = if (bean == null) null else SubItem3(bean.name, getByteArray(bean)) if (AsmUtils.traceSerializedClassEnabled && plain.name.contains(AsmUtils.traceSerializedClassPattern)) { if (mirrorC != null) AsmUtils.traceClass(mirrorC.jclassBytes) AsmUtils.traceClass(plainC.jclassBytes) - if (beanC != null) AsmUtils.traceClass(beanC.jclassBytes) } - q3 add Item3(arrivalPos, mirrorC, plainC, beanC, outFolder) + q3 add Item3(arrivalPos, mirrorC, plainC, outFolder) } @@ -280,7 +264,6 @@ abstract class GenBCode extends BCodeSyncAndTry { // initBytecodeWriter invokes fullName, thus we have to run it before the typer-dependent thread is activated. bytecodeWriter = initBytecodeWriter(cleanup.getEntryPoints) mirrorCodeGen = new JMirrorBuilder - beanInfoCodeGen = new JBeanInfoBuilder val needsOutfileForSymbol = bytecodeWriter.isInstanceOf[ClassBytecodeWriter] buildAndSendToDisk(needsOutfileForSymbol) @@ -355,7 +338,6 @@ abstract class GenBCode extends BCodeSyncAndTry { val outFolder = item.outFolder sendToDisk(item.mirror, outFolder) sendToDisk(item.plain, outFolder) - sendToDisk(item.bean, outFolder) expected += 1 } } diff --git a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala index 5a70d4c524c0..b2177b8941f4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala +++ b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala @@ -124,7 +124,7 @@ trait AnalyzerPlugins { self: Analyzer => * @param tpe The method type created by the namer for the accessor * @param typer The typer for the ValDef (not for the rhs) * @param tree The ValDef corresponding to the accessor - * @param sym The accessor method symbol (getter, setter, beanGetter or beanSetter) + * @param sym The accessor method symbol (getter, setter) */ def pluginsTypeSigAccessor(tpe: Type, typer: Typer, tree: ValDef, sym: Symbol): Type = tpe diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 20e462bbce8f..8e80b9bbd5fd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1094,15 +1094,6 @@ trait ContextErrors { def PrivateThisCaseClassParameterError(tree: Tree) = issueNormalTypeError(tree, "private[this] not allowed for case class parameters") - def BeanPropertyAnnotationLimitationError(tree: Tree) = - issueNormalTypeError(tree, "implementation limitation: the BeanProperty annotation cannot be used in a type alias or renamed import") - - def BeanPropertyAnnotationFieldWithoutLetterError(tree: Tree) = - issueNormalTypeError(tree, "`BeanProperty' annotation can be applied only to fields that start with a letter") - - def BeanPropertyAnnotationPrivateFieldError(tree: Tree) = - issueNormalTypeError(tree, "`BeanProperty' annotation can be applied only to non-private fields") - def DoubleDefError(currentSym: Symbol, prevSym: Symbol) = { val s1 = if (prevSym.isModule) "case class companion " else "" val s2 = if (prevSym.isSynthetic) "(compiler-generated) " + s1 else "" diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index ba183fe3e66e..b1f28a56f10d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -155,8 +155,6 @@ trait MethodSynthesis { else enterStrictVal(tree) } ) - - enterBeans(tree) } /** This is called for those ValDefs which addDerivedTrees ignores, but @@ -223,18 +221,10 @@ trait MethodSynthesis { else if (vd.mods.isLazy) List(LazyValGetter(vd)) else List(Getter(vd)) ) - def beanAccessors(vd: ValDef): List[DerivedFromValDef] = { - val setter = if (vd.mods.isMutable) List(BeanSetter(vd)) else Nil - if (vd.symbol hasAnnotation BeanPropertyAttr) - BeanGetter(vd) :: setter - else if (vd.symbol hasAnnotation BooleanBeanPropertyAttr) - BooleanBeanGetter(vd) :: setter - else Nil - } def allValDefDerived(vd: ValDef) = { val field = if (vd.mods.isDeferred || (vd.mods.isLazy && hasUnitType(vd.symbol))) Nil else List(Field(vd)) - field ::: standardAccessors(vd) ::: beanAccessors(vd) + field ::: standardAccessors(vd) } // Take into account annotations so that we keep annotated unit lazy val @@ -295,11 +285,10 @@ trait MethodSynthesis { final def enclClass = basisSym.enclClass /** Which meta-annotation is associated with this kind of entity. - * Presently one of: field, getter, setter, beanGetter, beanSetter, param. + * Presently one of: field, getter, setter, param. */ def category: Symbol - /* Explicit isSetter required for bean setters (beanSetterSym.isSetter is false) */ final def completer(sym: Symbol) = namerOf(sym).accessorTypeCompleter(tree, isSetter) final def fieldSelection = Select(This(enclClass), basisSym) final def derivedMods: Modifiers = mods & flagsMask | flagsExtra mapAnnotations (_ => Nil) @@ -475,71 +464,5 @@ trait MethodSynthesis { def validateParam(tree: ValDef) { Param(tree).derive(tree.symbol.annotations) } - - sealed abstract class BeanAccessor(bean: String) extends DerivedFromValDef { - val name = newTermName(bean + tree.name.toString.capitalize) - def flagsMask = BeanPropertyFlags - def flagsExtra = 0 - override def derivedSym = enclClass.info decl name - } - sealed trait AnyBeanGetter extends BeanAccessor with DerivedGetter { - def category = BeanGetterTargetClass - override def validate() { - if (derivedSym == NoSymbol) { - // the namer decides whether to generate these symbols or not. at that point, we don't - // have symbolic information yet, so we only look for annotations named "BeanProperty". - BeanPropertyAnnotationLimitationError(tree) - } - super.validate() - } - } - trait NoSymbolBeanGetter extends AnyBeanGetter { - // Derives a tree without attempting to use the original tree's symbol. - override def derivedTree = { - atPos(tree.pos.focus) { - DefDef(derivedMods, name, Nil, ListOfNil, tree.tpt.duplicate, - if (isDeferred) EmptyTree else Select(This(owner), tree.name) - ) - } - } - override def createAndEnterSymbol(): Symbol = enterSyntheticSym(derivedTree) - } - case class BooleanBeanGetter(tree: ValDef) extends BeanAccessor("is") with AnyBeanGetter { } - case class BeanGetter(tree: ValDef) extends BeanAccessor("get") with AnyBeanGetter { } - case class BeanSetter(tree: ValDef) extends BeanAccessor("set") with DerivedSetter { - def category = BeanSetterTargetClass - } - - // No Symbols available. - private def beanAccessorsFromNames(tree: ValDef) = { - val ValDef(mods, _, _, _) = tree - val hasBP = mods hasAnnotationNamed tpnme.BeanPropertyAnnot - val hasBoolBP = mods hasAnnotationNamed tpnme.BooleanBeanPropertyAnnot - - if (hasBP || hasBoolBP) { - val getter = ( - if (hasBP) new BeanGetter(tree) with NoSymbolBeanGetter - else new BooleanBeanGetter(tree) with NoSymbolBeanGetter - ) - getter :: { - if (mods.isMutable) List(BeanSetter(tree)) else Nil - } - } - else Nil - } - - protected def enterBeans(tree: ValDef) { - val ValDef(mods, name, _, _) = tree - val beans = beanAccessorsFromNames(tree) - if (beans.nonEmpty) { - if (!name.charAt(0).isLetter) - BeanPropertyAnnotationFieldWithoutLetterError(tree) - else if (mods.isPrivate) // avoids name clashes with private fields in traits - BeanPropertyAnnotationPrivateFieldError(tree) - - // Create and enter the symbols here, add the trees in finishGetterSetter. - beans foreach (_.createAndEnterSymbol()) - } - } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index fdff2f3076dc..605874c60eaa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -806,7 +806,7 @@ trait Namers extends MethodSynthesis { } } - /* Explicit isSetter required for bean setters (beanSetterSym.isSetter is false) */ + /* Explicit isSetter required for setters (beanSetterSym.isSetter is false) */ def accessorTypeCompleter(tree: ValDef, isSetter: Boolean) = mkTypeCompleter(tree) { sym => logAndValidate(sym) { sym setInfo { diff --git a/src/library/scala/NotImplementedError.scala b/src/library/scala/NotImplementedError.scala deleted file mode 100644 index 464a9a656d48..000000000000 --- a/src/library/scala/NotImplementedError.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - - -package scala - -/** Throwing this exception can be a temporary replacement for a method - * body that remains to be implemented. For instance, the exception is thrown by - * `Predef.???`. - */ -final class NotImplementedError(msg: String) extends Error(msg) { - def this() = this("an implementation is missing") -} diff --git a/src/library/scala/NotNull.scala b/src/library/scala/NotNull.scala deleted file mode 100644 index 3cbe9ed4ac09..000000000000 --- a/src/library/scala/NotNull.scala +++ /dev/null @@ -1,17 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala - -/** - * A marker trait for things that are not allowed to be null - * @since 2.5 - */ - -@deprecated("This trait will be removed", "2.11.0") -trait NotNull extends Any {} diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 7f717aa6e4cb..91269389c06a 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -131,13 +131,6 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef { @inline def locally[T](x: T): T = x // to communicate intent and avoid unmoored statements // errors and asserts ------------------------------------------------- - - // !!! Remove this when possible - ideally for 2.11. - // We are stuck with it a while longer because sbt's compiler interface - // still calls it as of 0.12.2. - @deprecated("Use `sys.error(message)` instead", "2.9.0") - def error(message: String): Nothing = sys.error(message) - /** Tests an expression, throwing an `AssertionError` if false. * Calls to this method will not be generated if `-Xelide-below` * is at least `ASSERTION`. @@ -220,27 +213,9 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef { } /** `???` can be used for marking methods that remain to be implemented. - * @throws A `NotImplementedError` + * @throws A `RuntimeException` */ - def ??? : Nothing = throw new NotImplementedError - - // tupling ------------------------------------------------------------ - - @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0") - type Pair[+A, +B] = Tuple2[A, B] - @deprecated("Use built-in tuple syntax or Tuple2 instead", "2.11.0") - object Pair { - def apply[A, B](x: A, y: B) = Tuple2(x, y) - def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x) - } - - @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0") - type Triple[+A, +B, +C] = Tuple3[A, B, C] - @deprecated("Use built-in tuple syntax or Tuple3 instead", "2.11.0") - object Triple { - def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z) - def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x) - } + def ??? : Nothing = throw new RuntimeException("undefined value evaluated") // implicit classes ----------------------------------------------------- @@ -501,6 +476,7 @@ private[scala] abstract class LowPriorityImplicits { implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null implicit def unwrapString(ws: WrappedString): String = if (ws ne null) ws.self else null + implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]] = new CanBuildFrom[String, T, immutable.IndexedSeq[T]] { diff --git a/src/library/scala/annotation/compileTimeOnly.scala b/src/library/scala/annotation/compileTimeOnly.scala index 942e9cad8c7d..16266891616f 100644 --- a/src/library/scala/annotation/compileTimeOnly.scala +++ b/src/library/scala/annotation/compileTimeOnly.scala @@ -18,5 +18,5 @@ import scala.annotation.meta._ * after type checking * @since 2.11.0 */ -@getter @setter @beanGetter @beanSetter @companionClass @companionMethod +@companionClass @companionMethod final class compileTimeOnly(message: String) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/beanGetter.scala b/src/library/scala/annotation/meta/beanGetter.scala deleted file mode 100644 index ce4207e1352c..000000000000 --- a/src/library/scala/annotation/meta/beanGetter.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ -package scala.annotation.meta - -/** - * Consult the documentation in package [[scala.annotation.meta]]. - */ -final class beanGetter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/beanSetter.scala b/src/library/scala/annotation/meta/beanSetter.scala deleted file mode 100644 index ad3093240017..000000000000 --- a/src/library/scala/annotation/meta/beanSetter.scala +++ /dev/null @@ -1,13 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ -package scala.annotation.meta - -/** - * Consult the documentation in package [[scala.annotation.meta]]. - */ -final class beanSetter extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/annotation/meta/package.scala b/src/library/scala/annotation/meta/package.scala index 2d18ae5dd714..3db72d737344 100644 --- a/src/library/scala/annotation/meta/package.scala +++ b/src/library/scala/annotation/meta/package.scala @@ -3,12 +3,11 @@ package scala.annotation /** * When defining a field, the Scala compiler creates up to four accessors * for it: a getter, a setter, and if the field is annotated with - * `@BeanProperty`, a bean getter and a bean setter. * * For instance in the following class definition * * {{{ - * class C(@myAnnot @BeanProperty var c: Int) + * class C(@myAnnot var c: Int) * }}} * * there are six entities which can carry the annotation `@myAnnot`: the @@ -27,30 +26,12 @@ package scala.annotation * * The target meta-annotations can be put on the annotation type when * instantiating the annotation. In the following example, the annotation - * `@Id` will be added only to the bean getter `getX`. - * - * {{{ - * import javax.persistence.Id - * class A { - * @(Id @beanGetter) @BeanProperty val x = 0 - * } - * }}} * * In order to annotate the field as well, the meta-annotation `@field` * would need to be added. * * The syntax can be improved using a type alias: * - * {{{ - * object ScalaJPA { - * type Id = javax.persistence.Id @beanGetter - * } - * import ScalaJPA.Id - * class A { - * @Id @BeanProperty val x = 0 - * } - * }}} - * * ==Annotating the annotation class== * * For annotations defined in Scala, a default target can be specified diff --git a/src/library/scala/beans/BeanDescription.scala b/src/library/scala/beans/BeanDescription.scala deleted file mode 100644 index a9c748dfe75b..000000000000 --- a/src/library/scala/beans/BeanDescription.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.beans - -/** Provides a short description that will be included when generating - * bean information. This annotation can be attached to the bean itself, - * or to any member. - * - * @author Ross Judson (rjudson@managedobjects.com) - */ -class BeanDescription(val description: String) extends scala.annotation.Annotation - diff --git a/src/library/scala/beans/BeanDisplayName.scala b/src/library/scala/beans/BeanDisplayName.scala deleted file mode 100644 index 5937c6517b8c..000000000000 --- a/src/library/scala/beans/BeanDisplayName.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.beans - -/** Provides a display name when generating bean information. This - * annotation can be attached to the bean itself, or to any member. - * - * @author Ross Judson (rjudson@managedobjects.com) - */ -class BeanDisplayName(val name: String) extends scala.annotation.Annotation - diff --git a/src/library/scala/beans/BeanInfoSkip.scala b/src/library/scala/beans/BeanInfoSkip.scala deleted file mode 100644 index ccbb19385413..000000000000 --- a/src/library/scala/beans/BeanInfoSkip.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.beans - -/** This annotation indicates that bean information should - * not be generated for the val, var, or def that it is - * attached to. - * - * @author Ross Judson (rjudson@managedobjects.com) - */ -class BeanInfoSkip extends scala.annotation.Annotation diff --git a/src/library/scala/beans/ScalaBeanInfo.scala b/src/library/scala/beans/ScalaBeanInfo.scala deleted file mode 100644 index ac8fa263d7f5..000000000000 --- a/src/library/scala/beans/ScalaBeanInfo.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - - -package scala.beans - -/** Provides some simple runtime processing necessary to create - * JavaBean descriptors for Scala entities. The compiler creates - * subclasses of this class automatically when the BeanInfo annotation is - * attached to a class. - * - * @author Ross Judson (rjudson@managedobjects.com) - */ -abstract class ScalaBeanInfo(clazz: java.lang.Class[_], - props: Array[String], - methods: Array[String]) extends java.beans.SimpleBeanInfo { - - import java.beans._ - - private val pd = new Array[PropertyDescriptor](props.length / 3) - private val md = - for (m <- clazz.getMethods if methods.exists(_ == m.getName)) - yield new MethodDescriptor(m) - - init() - - override def getPropertyDescriptors() = pd - override def getMethodDescriptors() = md - - // override def getAdditionalBeanInfo() = Array(Introspector getBeanInfo clazz.getSuperclass) - - private def init() { - var i = 0 - while (i < props.length) { - pd(i/3) = new PropertyDescriptor(props(i), clazz, props(i+1), props(i+2)) - i = i + 3 - } - } - -} - diff --git a/src/library/scala/deprecated.scala b/src/library/scala/deprecated.scala index e940a4bfbe2e..4628aafe4fee 100644 --- a/src/library/scala/deprecated.scala +++ b/src/library/scala/deprecated.scala @@ -17,5 +17,4 @@ import scala.annotation.meta._ * @param since a string identifying the first version in which the definition was deprecated * @since 2.3 */ -@getter @setter @beanGetter @beanSetter class deprecated(message: String = "", since: String = "") extends scala.annotation.StaticAnnotation diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index fcef4dd6be6b..0f45d5f4db84 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -298,7 +298,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => /** The default kind of members to which this annotation is attached. * For instance, for scala.deprecated defaultTargets = - * List(getter, setter, beanGetter, beanSetter). + * List(getter, setter). */ def defaultTargets = symbol.annotations map (_.symbol) filter isMetaAnnotation // Test whether the typeSymbol of atp conforms to the given class. diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 02578e20386f..3ef8fdb42243 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -1099,8 +1099,6 @@ trait Definitions extends api.StandardDefinitions { lazy val uncheckedStableClass = requiredClass[scala.annotation.unchecked.uncheckedStable] lazy val uncheckedVarianceClass = requiredClass[scala.annotation.unchecked.uncheckedVariance] - lazy val BeanPropertyAttr = requiredClass[scala.beans.BeanProperty] - lazy val BooleanBeanPropertyAttr = requiredClass[scala.beans.BooleanBeanProperty] lazy val CompileTimeOnlyAttr = getClassIfDefined("scala.annotation.compileTimeOnly") lazy val DeprecatedAttr = requiredClass[scala.deprecated] lazy val DeprecatedNameAttr = requiredClass[scala.deprecatedName] @@ -1121,8 +1119,6 @@ trait Definitions extends api.StandardDefinitions { lazy val VolatileAttr = requiredClass[scala.volatile] // Meta-annotations - lazy val BeanGetterTargetClass = requiredClass[meta.beanGetter] - lazy val BeanSetterTargetClass = requiredClass[meta.beanSetter] lazy val FieldTargetClass = requiredClass[meta.field] lazy val GetterTargetClass = requiredClass[meta.getter] lazy val ParamTargetClass = requiredClass[meta.param] diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 170706181761..48d294b26368 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -281,7 +281,6 @@ class Flags extends ModifierFlags { * SYNTHETIC. */ final val ValueParameterFlags = BYNAMEPARAM | IMPLICIT | DEFAULTPARAM | STABLE | SYNTHETIC - final val BeanPropertyFlags = DEFERRED | OVERRIDE | STATIC final val VarianceFlags = COVARIANT | CONTRAVARIANT /** These appear to be flags which should be transferred from owner symbol diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 6848c357c5eb..e0354b842388 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -258,8 +258,6 @@ trait StdNames { final val QUASIQUOTE_TUPLE: NameType = "$quasiquote$tuple$" // Annotation simple names, used in Namer - final val BeanPropertyAnnot: NameType = "BeanProperty" - final val BooleanBeanPropertyAnnot: NameType = "BooleanBeanProperty" final val bridgeAnnot: NameType = "bridge" // Classfile Attributes diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index dcd262c288cc..f12d1b77c531 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -370,8 +370,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => definitions.VarargsClass definitions.uncheckedStableClass definitions.uncheckedVarianceClass - definitions.BeanPropertyAttr - definitions.BooleanBeanPropertyAttr definitions.CompileTimeOnlyAttr definitions.DeprecatedAttr definitions.DeprecatedNameAttr @@ -390,8 +388,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => definitions.UncheckedBoundsClass definitions.UnspecializedClass definitions.VolatileAttr - definitions.BeanGetterTargetClass - definitions.BeanSetterTargetClass definitions.FieldTargetClass definitions.GetterTargetClass definitions.ParamTargetClass diff --git a/src/repl/scala/tools/nsc/Interpreter.scala b/src/repl/scala/tools/nsc/Interpreter.scala deleted file mode 100644 index 434f19f21b04..000000000000 --- a/src/repl/scala/tools/nsc/Interpreter.scala +++ /dev/null @@ -1,12 +0,0 @@ -package scala.tools.nsc - -import interpreter._ -import java.io._ - -/** A compatibility stub. - */ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") -class Interpreter(settings: Settings, out: PrintWriter) extends IMain(settings, out) { - def this(settings: Settings) = this(settings, new NewLinePrintWriter(new ConsoleWriter, true)) - def this() = this(new Settings()) -} \ No newline at end of file diff --git a/src/repl/scala/tools/nsc/InterpreterLoop.scala b/src/repl/scala/tools/nsc/InterpreterLoop.scala deleted file mode 100644 index a0be3f4fdbd2..000000000000 --- a/src/repl/scala/tools/nsc/InterpreterLoop.scala +++ /dev/null @@ -1,12 +0,0 @@ -package scala.tools.nsc - -import interpreter._ -import java.io._ - -/** A compatibility stub. - */ -@deprecated("Use a class in the scala.tools.nsc.interpreter package.", "2.9.0") -class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) extends ILoop(in0, out) { - def this(in0: BufferedReader, out: PrintWriter) = this(Some(in0), out) - def this() = this(None, new PrintWriter(scala.Console.out)) -} diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index 50c89f7442ea..372d64d309ab 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -43,9 +43,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) def this(in0: BufferedReader, out: JPrintWriter) = this(Some(in0), out) def this() = this(None, new JPrintWriter(Console.out, true)) - @deprecated("Use `intp` instead.", "2.9.0") def interpreter = intp - @deprecated("Use `intp` instead.", "2.9.0") def interpreter_= (i: Interpreter): Unit = intp = i - var in: InteractiveReader = _ // the input stream from which commands come var settings: Settings = _ var intp: IMain = _ diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 6e30b73e0ef6..2c7df6d9b200 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -9,7 +9,6 @@ package interpreter import PartialFunction.cond import scala.language.implicitConversions -import scala.beans.BeanProperty import scala.collection.mutable import scala.concurrent.{ Future, ExecutionContext } import scala.reflect.runtime.{ universe => ru } @@ -54,7 +53,7 @@ import javax.script.{AbstractScriptEngine, Bindings, ScriptContext, ScriptEngine * @author Moez A. Abdel-Gawad * @author Lex Spoon */ -class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Settings, protected val out: JPrintWriter) extends AbstractScriptEngine with Compilable with Imports { +class IMain(val factory: ScriptEngineFactory, initialSettings: Settings, protected val out: JPrintWriter) extends AbstractScriptEngine with Compilable with Imports { imain => setBindings(createBindings, ScriptContext.ENGINE_SCOPE) @@ -82,6 +81,8 @@ class IMain(@BeanProperty val factory: ScriptEngineFactory, initialSettings: Set private var _classLoader: util.AbstractFileClassLoader = null // active classloader private val _compiler: ReplGlobal = newCompiler(settings, reporter) // our private compiler + def getFactory(): ScriptEngineFactory = factory + def compilerClasspath: Seq[java.net.URL] = ( if (isInitializeComplete) global.classPath.asURLs else new PathResolver(settings).result.asURLs // the compiler's classpath @@ -1210,29 +1211,30 @@ object IMain { import java.util.Arrays.{ asList => asJavaList } class Factory extends ScriptEngineFactory { - @BeanProperty val engineName = "Scala Interpreter" - @BeanProperty val engineVersion = "1.0" - @BeanProperty val extensions: JList[String] = asJavaList("scala") - @BeanProperty val languageName = "Scala" - @BeanProperty val languageVersion = scala.util.Properties.versionString def getMethodCallSyntax(obj: String, m: String, args: String*): String = null - @BeanProperty val mimeTypes: JList[String] = asJavaList("application/x-scala") - @BeanProperty val names: JList[String] = asJavaList("scala") + def getEngineName(): String = engineName + def getEngineVersion(): String = engineVersion + def getExtensions(): JList[String] = extensions + def getLanguageName(): String = languageName + def getLanguageVersion(): String = languageVersion + def getMimeTypes(): java.util.List[String] = mimeTypes + def getNames(): java.util.List[String] = names + def getOutputStatement(toDisplay: String): String = null def getParameter(key: String): Object = key match { diff --git a/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala index 910148532d39..d9cae0cc7e75 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -30,8 +30,7 @@ private[html] object SyntaxHigh { /** Annotations, sorted alphabetically */ val annotations = Array( - "BeanProperty", "SerialVersionUID", - "beanGetter", "beanSetter", "bridge", + "SerialVersionUID", "bridge", "deprecated", "deprecatedName", "deprecatedOverriding", "deprecatedInheritance", "elidable", "field", "getter", "inline", "migration", "native", "noinline", "param", diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index c42eceef4cab..1f6dac71f68f 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -96,21 +96,6 @@ object Test4 { def this() = this("") } class Foo8(@SourceAnnotation("constructor val") val n: Int) {} - class Foo9 { - import scala.annotation.meta._ - import scala.beans.BeanProperty - @(SourceAnnotation @getter)("http://apple.com") val x = 0 - @BeanProperty @(SourceAnnotation @beanSetter)("http://uppla.com") var y = 0 - - type myAnn = SourceAnnotation @beanGetter @field - @BeanProperty @myAnn("http://eppli.com") var z = 0 - - type myAnn2[T] = SourceAnnotation @beanGetter @field - @BeanProperty @myAnn2[String]("http://eppli.com") var z2 = 0 - - type myAnn3[CC[_]] = SourceAnnotation @beanGetter @field - @BeanProperty @myAnn3[List]("http://eppli.com") var z3 = 0 - } class Foo10(@SourceAnnotation("on param 1") val name: String) class Foo11(@(SourceAnnotation @scala.annotation.meta.field)("on param 2") val name: String) class Foo12(@(SourceAnnotation @scala.annotation.meta.setter)("on param 3") var name: String) @@ -165,51 +150,6 @@ object Test4 { } } -object Test5 { - import scala.beans.BeanProperty - import java.lang.Integer - - class Count { - // we use "Integer" instead of "Int" because of Java reflection - @BeanProperty - var count: Integer = 0 - - private val getter = - getClass().getMethod("getCount") - private val setter = - getClass().getMethod("setCount", classOf[Integer]) - - def get = getter.invoke(this).asInstanceOf[Integer].intValue - def set(n: Int) = setter.invoke(this, new Integer(n)) - } - def run { - val count = new Count - println(count.get) - count.set(99) - println(count.get) - } -} - -object Test6 { - import scala.beans.BeanProperty - import scala.beans.BooleanBeanProperty - class C(@BeanProperty var text: String) - class D(@BooleanBeanProperty var prop: Boolean) { - @BeanProperty val m: Int = if (prop) 1 else 2 - } - - def run { - val c = new C("bob") - c.setText("dylan") - println(c.getText()) - val d = new D(true) - d.setProp(false) - if (!d.isProp()) { - println(new D(false).getM()) - } - } -} - // #3345 class A3345(@volatile private var i:Int) diff --git a/test/files/jvm/beanInfo/C_1.scala b/test/files/jvm/beanInfo/C_1.scala deleted file mode 100644 index a338abea1d28..000000000000 --- a/test/files/jvm/beanInfo/C_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -package p - -@scala.beans.BeanInfo -class C { - val x: Int = 0 - var y: String = "" - var z: List[_] = Nil - def f: C = ??? -} diff --git a/test/files/jvm/beanInfo/Test_2.scala b/test/files/jvm/beanInfo/Test_2.scala deleted file mode 100644 index fa9b6e139129..000000000000 --- a/test/files/jvm/beanInfo/Test_2.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test extends App { - val info = java.beans.Introspector.getBeanInfo(classOf[p.C]) - - println("property descriptors") - - val pds = info.getPropertyDescriptors - for (pd <- pds) { - println(s"${pd.getName} -- ${pd.getPropertyType} -- ${pd.getReadMethod} -- ${pd.getWriteMethod}") - } - - println("method descriptors") - - val mds = info.getMethodDescriptors - for (md <- mds) { - println(s"${md.getName} -- ${md.getMethod}") - } -} diff --git a/test/files/jvm/t8582.check b/test/files/jvm/t8582.check index 564f482ff87f..6d6ee701883b 100644 --- a/test/files/jvm/t8582.check +++ b/test/files/jvm/t8582.check @@ -29,10 +29,6 @@ Because that attribute leads to an entry for B1 in the constant pool, C1 needs a className[A1$B1] outerClassName[A1] innerName[B1] access[1] className[A1$B1$C1] outerClassName[A1$B1] innerName[C1] access[1] -The BeanInfo class has the same InnerClass attributes as the corresponding bean - className[A1$B1] outerClassName[A1] innerName[B1] access[1] - className[A1$B1$C1] outerClassName[A1$B1] innerName[C1] access[1] - Class A2 mentions class C2 in the constant pool (due to method f), therefore it needs an InnerClass attribute for C1 className[A2$B2] outerClassName[A2] innerName[B2] access[1] className[A2$B2$C2] outerClassName[A2$B2] innerName[C2] access[1] diff --git a/test/files/jvm/t8582.scala b/test/files/jvm/t8582.scala deleted file mode 100644 index 8a57ef795239..000000000000 --- a/test/files/jvm/t8582.scala +++ /dev/null @@ -1,81 +0,0 @@ -import scala.tools.partest.BytecodeTest -import scala.collection.JavaConverters._ - -package p1 { - package p2 { - object Singleton { - object Singleton { - object Singleton - } - } - } -} - -class A1 { - class B1 { - @scala.beans.BeanInfo - class C1 - } -} - -class A2 { - class B2 { - class C2 - } - def f: B2#C2 = null -} - - -object Test extends BytecodeTest { - import p1.p2._ - - def nested(c: Class[_]) = s" ${c.getName}: ${c.getDeclaredClasses.toList}" - - def nprintln(s: String) = println("\n"+s) - def printInner(cname: String): Unit = { - val cnode = loadClassNode(cname) - println(cnode.innerClasses.asScala.toList.map(i => s"className[${i.name}] outerClassName[${i.outerName}] innerName[${i.innerName}] access[${i.access}]").mkString(" ", "\n ", "")) - } - - def show() { - - println("getClass on module gives module class") - println(" " + Singleton.Singleton.getClass) - - nprintln("Nested module classes are found through reflection") - println(nested(Singleton.Singleton.getClass)) - - nprintln("Reflection can find direct nested classes (A1-B1-C1)") - println(nested(classOf[A1])) - println(nested(classOf[A1#B1])) - println(nested(classOf[A1#B1#C1])) - - nprintln("Reflection can find direct nested classes (A2-B2-C2)") - println(nested(classOf[A2])) - println(nested(classOf[A2#B2])) - println(nested(classOf[A2#B2#C2])) - - nprintln("Mirror classes have the same InnerClass attributes as the corresponding module class:") - printInner("p1.p2.Singleton") // mirror class - println("Module class") - printInner("p1.p2.Singleton$") - - nprintln("An outer class has a InnerClass attribute for direct nested classes") - printInner("A1") - println("A nested class has an InnerClass attribute for itself (and also for its nested classes)") - printInner("A1$B1") - println("C1 is a nested class, so it has an InnerClass attribute for itself.\n"+ - "Because that attribute leads to an entry for B1 in the constant pool, C1 needs an InnerClass attribute for B1.") - printInner("A1$B1$C1") - - nprintln("The BeanInfo class has the same InnerClass attributes as the corresponding bean") - printInner("A1$B1$C1BeanInfo") - - nprintln("Class A2 mentions class C2 in the constant pool (due to method f), therefore it needs an InnerClass attribute for C1") - printInner("A2") - println("B2") - printInner("A2$B2") - println("C2") - printInner("A2$B2$C2") - } -} diff --git a/test/files/neg/t3403.check b/test/files/neg/t3403.check deleted file mode 100644 index e52d140e6a42..000000000000 --- a/test/files/neg/t3403.check +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 7cf0c3e0f7fc..000000000000 --- a/test/files/neg/t3403.scala +++ /dev/null @@ -1,2 +0,0 @@ -import scala.beans.{BeanProperty => bp} -class Foo { @bp var bar: Int = 1 } diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala deleted file mode 100644 index 4832ce4ecdf7..000000000000 --- a/test/files/pos/annotations.scala +++ /dev/null @@ -1,110 +0,0 @@ -class ann(i: Int) extends scala.annotation.Annotation -class cfann(x: String) extends annotation.ClassfileAnnotation - -// annotations on abstract types -abstract class C1[@annotation.elidable(0) +T, U, V[_]] -abstract class C2[@deprecated - @ann(1) T <: Number, - V] -abstract class C3 { - @ann(2) type X <: Number -} - -object Test { - - // bug #1028 - val x = 1 - @ann(x) val a = () - @ann({val yy = 2; yy}) val b = () - val bb: Int @ann({val yy = 2; yy}) = 10 - - def c: Int @ann(x) = 1 - def d: String @ann({val z = 0; z - 1}) = "2" - def e[@deprecated T, U](x: T) = x - - //bug #1214 - val y = new (Integer @ann(0))(2) - - import scala.beans.BeanProperty - - // bug #637 - trait S { def getField(): Int } - class O extends S { @BeanProperty val field = 0 } - - // bug #1070 - trait T { @BeanProperty var field = 1 } - - // annotation on annotation constructor - @(ann @ann(100))(200) def foo() = 300 - - // #2984 - private final val NAMESPACE = "/info" - @cfann(x = NAMESPACE + "/index") def index = "success" -} - -// test forward references to getters / setters -class BeanPropertyTests { - @scala.beans.BeanProperty lazy val lv1 = 0 - - def foo() { - val bp1 = new BeanPropertyTests1 - - println(lv1) - println(getLv1()) - println(bp1.getLv2()) - - println(getV1()) - setV1(10) - bp1.setV2(100) - } - - @scala.beans.BeanProperty var v1 = 0 - -} - -class BeanPropertyTests1 { - @scala.beans.BeanProperty lazy val lv2 = "0" - @scala.beans.BeanProperty var v2 = 0 -} - -// test mixin of getters / setters, and implementing abstract -// methods using @BeanProperty -class C extends T with BeanF { - def foo() { - setF("doch!") - setG(true) - this.getF() - } -} - -trait T { - @scala.beans.BeanProperty var f = "nei" - @scala.beans.BooleanBeanProperty var g = false -} - -trait BeanF { - def getF(): String - def setF(n: String): Unit - - def isG(): Boolean - def setG(nb: Boolean): Unit -} - - -class Ann3(arr: Array[String]) extends annotation.ClassfileAnnotation -class Ann4(i: Int) extends annotation.ClassfileAnnotation -class Ann5(value: Class[_]) extends annotation.ClassfileAnnotation - -object Test3 { - final val i = 1083 - final val cls = classOf[String] -} - -class Test4 { - @Ann3(arr = Array("dlkfj", "DSF")) - @Ann4(i = 2908) - @Ann4(i = Test3.i) - @Ann5(value = classOf[Int]) - @Ann5(Test3.cls) - def foo {} -} diff --git a/test/files/pos/spec-annotations.scala b/test/files/pos/spec-annotations.scala deleted file mode 100644 index b23abf48e8cf..000000000000 --- a/test/files/pos/spec-annotations.scala +++ /dev/null @@ -1,35 +0,0 @@ -class ann(i: Int) extends scala.annotation.Annotation - -// annotations on abstract types -abstract class C1[@annotation.elidable(0) +T, U, V[_]] -abstract class C2[@deprecated - @ann(1) T <: Number, - V] -abstract class C3 { - @ann(2) type X <: Number -} - -object Test { - - // bug #1028 - val x = 1 - @ann(x) val a = () - @ann({val y = 2; y}) val b = () - - def c: Int @ann(x) = 1 - def d: String @ann({val z = 0; z - 1}) = "2" - def e[@deprecated T, U](x: T) = x - - //bug #1214 - val y = new (Integer @ann(0))(2) - - import scala.beans.BeanProperty - - // bug #637 - trait S { def getField(): Int } - class O extends S { @BeanProperty val field = 0 } - - // bug #1070 - trait T { @BeanProperty var field = 1 } -} - diff --git a/test/files/pos/t1070.scala b/test/files/pos/t1070.scala deleted file mode 100644 index 1622043a85d8..000000000000 --- a/test/files/pos/t1070.scala +++ /dev/null @@ -1,4 +0,0 @@ -import scala.beans.BeanProperty; -trait beanpropertytrait { - @BeanProperty var myVariable: Long = -1l; -} diff --git a/test/files/pos/t1782/Test_1.scala b/test/files/pos/t1782/Test_1.scala deleted file mode 100644 index 6467a74c2974..000000000000 --- a/test/files/pos/t1782/Test_1.scala +++ /dev/null @@ -1,16 +0,0 @@ -@ImplementedBy(classOf[Provider]) -trait Service { - def someMethod() -} - -class Provider - extends Service -{ - // test enumeration java annotations - @Ann(Days.Friday) def someMethod() = () - - // #2103 - @scala.beans.BeanProperty - @Ann(value = Days.Sunday) - val t2103 = "test" -} diff --git a/test/files/run/reify_ann5.check b/test/files/run/reify_ann5.check deleted file mode 100644 index 1ec0457e542c..000000000000 --- a/test/files/run/reify_ann5.check +++ /dev/null @@ -1,22 +0,0 @@ -{ - class C extends AnyRef { - @new inline @beanGetter() @new BeanProperty() val x: Int = _; - def (x: Int) = { - super.(); - () - } - }; - () -} -{ - class C extends AnyRef { - @scala.beans.BeanProperty private[this] val x: Int = _; - def x: Int = C.this.x; - def (x: Int): C = { - C.super.(); - () - }; - @inline @scala.annotation.meta.beanGetter def getX(): Int = C.this.x - }; - () -} diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala deleted file mode 100644 index 5e2f058a39bb..000000000000 --- a/test/files/run/reify_ann5.scala +++ /dev/null @@ -1,23 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{universe => ru} -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.ToolBox -import scala.annotation._ -import scala.annotation.meta._ -import scala.beans._ - -object Test extends App { - // test 1: reify - val tree = reify{ - class C(@BeanProperty @(inline @beanGetter) val x: Int) - }.tree - println(tree.toString) - - // test 2: import and typecheck - val toolbox = cm.mkToolBox() - val ttree = toolbox.typecheck(tree) - println(ttree.toString) - - // test 3: import and compile - toolbox.eval(tree) -} \ No newline at end of file