diff options
author | Martin Odersky <odersky@gmail.com> | 2008-05-02 15:01:17 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-05-02 15:01:17 +0000 |
commit | e1e4aebdba268815d08bd6137974290cfc7b34dd (patch) | |
tree | 17d4e31641a8b5a2827d44f15004dd52a9b744b0 | |
parent | 1e22d56b57a4aa40a916e2d111100f195cd82cea (diff) | |
download | scala-e1e4aebdba268815d08bd6137974290cfc7b34dd.tar.gz scala-e1e4aebdba268815d08bd6137974290cfc7b34dd.tar.bz2 scala-e1e4aebdba268815d08bd6137974290cfc7b34dd.zip |
fixed #828, #789
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 20 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/Tree.scala | 53 |
2 files changed, 71 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index de1f3f3119..d22ab4942e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -249,8 +249,20 @@ abstract class RefChecks extends InfoTransform { else clazz.toString() + " needs to be abstract") + ", since " + msg); clazz.setFlag(ABSTRACT) } + // Find a concrete Java method that overrides `sym' under the erasure model. + // Bridge symbols qualify. + // Used as a fall back if no overriding symbol of a Java abstract method can be found + def javaErasedOverridingSym(sym: Symbol): Symbol = + clazz.tpe.findMember(sym.name, PRIVATE, 0, false).filter(other => + !other.isDeferred && + (other hasFlag JAVA) && { + val tp1 = erasure.erasure(clazz.thisType.memberType(sym)) + val tp2 = erasure.erasure(clazz.thisType.memberType(other)) + atPhase(currentRun.erasurePhase.next)(tp1 matches tp2) + }) for (val member <- clazz.tpe.nonPrivateMembers) - if (member.isDeferred && !(clazz hasFlag ABSTRACT)) { + if (member.isDeferred && !(clazz hasFlag ABSTRACT) && + !((member hasFlag JAVA) && javaErasedOverridingSym(member) != NoSymbol)) { abstractClassError( false, infoString(member) + " is not defined" + analyzer.varNotice(member)) } else if ((member hasFlag ABSOVERRIDE) && member.isIncompleteIn(clazz)) { @@ -263,6 +275,12 @@ abstract class RefChecks extends InfoTransform { } // 3. Check that concrete classes do not have deferred definitions // that are not implemented in a subclass. + // Note that this is not the same as (2); In a situation like + // + // class C { def m: Int = 0} + // class D extends C { def m: Int } + // + // (3) is violated but not (2). def checkNoAbstractDecls(bc: Symbol) { for (val decl <- bc.info.decls.elements) { if (decl.isDeferred) { diff --git a/src/library/scala/collection/immutable/Tree.scala b/src/library/scala/collection/immutable/Tree.scala index 3853e23cd9..99a123273c 100644 --- a/src/library/scala/collection/immutable/Tree.scala +++ b/src/library/scala/collection/immutable/Tree.scala @@ -17,7 +17,11 @@ ** Balanced Trees. These have no storage overhead compared to plain ** unbalanced binary trees, and their performance is in general better ** than AVL trees. -* +** +** NOTE: This code was until 2007-04-01 under a GPL license. The author has +** given permission to remove that license, so that now this code is under +** the general license for the Scala libraries. I include his mail at the +** bottom of this file for reference. */ package scala.collection.immutable @@ -387,3 +391,50 @@ private case class GBNode[A <% Ordered[A],B](key: A, override def hashCode() = value.hashCode() + smaller.hashCode() + bigger.hashCode() } + +/* Here is the e-mail where the Author agreed to the change in license. + +from Erik Stenman <happi.stenman@gmail.com> +to martin odersky <martin.odersky@epfl.ch>, +date Tue, Apr 29, 2008 at 3:31 PM +subject Re: test +mailed-by chara.epfl.ch +signed-by gmail.com + +Hi Martin, + +I am fine with that change, and since I don't have a scala distribution handy, +I am also fine with you doing the change yourself. Is that OK? + +Sorry for my dead home address, I'll add an English response to it at some time. + +I am doing fine, and my family is also doing fine. +Hope all is well with you too. + +Cheers, +Erik +- Hide quoted text - + +On Tue, Apr 29, 2008 at 3:13 PM, martin odersky <martin.odersky@epfl.ch> wrote: + + Hi Erik, + + I tried to send mail to happi@home.se, but got a response n swedish. I + was sort of guessing from the response that it contained an + alternative e-mail address and tried to send it there. + + Anyway, I hope things are going well with you! + + There was some discussion recently about the license of Tree.scala in + package collection.immutable. It's GPL, whereas the rest of the Scala + library is BSD. It seems this poses problems with Scala being packaged + with Fedora. Would it be OK with you to change the license to the + general one of Scala libraries? You could simply remove the references + to the GPL + license in the code and send it back to me if that's OK with you. On + the other hand, if there's a problem we'll try something else instead. + + All the best + + -- Martin +*/ |