summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Optimizing TypeRef, starting with Symbols.Paul Phillips2012-01-111-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are too many potential optimizations unavailable to us due to the lack of bright lines among different kinds of symbols. For instance the difference between a TypeSymbol which represents a type alias and one which represents an abstract type is only whether the DEFERRED flag is set. This creates issues. 1) There are many (many) places where tests are performed on every symbol which could be done more efficiently and (especially) more verifiably correctly with polymorphism. 2) TypeRefs based on those symbols are also checking that flag constantly, in perpetuity. A symbol created as an alias is never (to the best of my knowledge) going to intentionally morph into one representing an abstract type, nor vice versa. 3) One has no guarantees, because anyone can set or reset the DEFERRED flag at any time. So tackling more than one problem at once herein: 1) I created canonical symbol creation points which take the flags as an argument, so that there can be a difference between initializing a symbol's flags and setting/resetting them at arbitrary times. 2) I structured all the symbol creators to take arguments in the same order, which is: def newXXX(name: Name, ..., pos: Position = NoPosition, flags: Long = 0L) (Where "..." is for those symbols which require something beyond the name to create, such as a TypeSkolem's origin.) The name is first because it's the only always required argument. I left but deprecated the variations which take (pos, name). 3) I created subclasses of TypeRef based on the information which should be stable from creation time onward: - args or no args? - abstract type, type alias, or class? 2x3 == 6 and that's how many subclasses of TypeRef there are now. So now, for example, every TypeRef doesn't have to carry null symInfoCache and thisInfoCache fields for the benefit of the minority which use them. I still intend to realize the gain possible once we can evade the fields for pre and args without losing pattern matcher efficiency.
* Disabling some scaladoc tests.Paul Phillips2012-01-111-17/+17
| | | | | | | | | | | These tests are WAY too difficult to work with. I don't have a clue what these failures are telling me, except they are telling me to disable them. Actual output: [partest] Check failed: [partest] HTML: SI_5054_q1classSI_5054_q1extendsAnyRefLinearSupertypesAnyRef,AnyOrderingAlphabeticByinheritanceInheritedHideAllShowallSI_5054_q1AnyRefAnyVisibilityPublicAllInstanceConstructorsnewSI_5054_q1()ValueMembersfinaldef!=(arg0:AnyRef):BooleanDefinitionClassesAnyReffinaldef!=(arg0:Any):BooleanDefinitionClassesAnyfinaldef##():IntDefinitionClassesAnyRefAnyfinaldef==(arg0:AnyRef):BooleanDefinitionClassesAnyReffinaldef==(arg0:Any):BooleanDefinitionClassesAnyfinaldefasInstanceOf[T0]:T0DefinitionClassesAnydefclone():AnyRefAttributesprotected[lang]DefinitionClassesAnyRefAnnotations@throws()finaldefeq(arg0:AnyRef):BooleanDefinitionClassesAnyRefdefequals(arg0:Any):BooleanDefinitionClassesAnyRefAnydeffinalize():UnitAttributesprotected[lang]DefinitionClassesAnyRefAnnotations@throws()finaldefgetClass():Class[_]DefinitionClassesAnyRefAnydefhashCode():IntDefinitionClassesAnyRefAnyfinaldefisInstanceOf[T0]:BooleanDefinitionClassesAnyfinaldefne(arg0:AnyRef):BooleanDefinitionClassesAnyReffinaldefnotify():UnitDefinitionClassesAnyReffinaldefnotifyAll():UnitDefinitionClassesAnyReffinaldefsynchronized[T0](arg0:⇒T0):T0DefinitionClassesAnyRefdeftest():Int[usecase]deftoString():StringDefinitionClassesAnyRefAnyfinaldefwait():UnitDefinitionClassesAnyRefAnnotations@throws()finaldefwait(arg0:Long,arg1:Int):UnitDefinitionClassesAnyRefAnnotations@throws()finaldefwait(arg0:Long):UnitDefinitionClassesAnyRefAnnotations@throws()InheritedfromAnyRefInheritedfromAny
* Updated checkfile with IndexedSeq signature.Paul Phillips2012-01-111-1/+1
|
* Revert "Accept prefixed xml attributes with null value"Paul Phillips2012-01-101-22/+3
| | | | | This reverts commit 51089b34a7a535498dee42e6465d4d577d65b7d5. A scaladoc test is failing and I have no time to look at it.
* Better error reporting regarding main methods.Paul Phillips2012-01-094-10/+83
| | | | | | Now notices most things which look like main methods and says something useful if they aren't usable as entry points. Closes SI-4749.
*---. Merge remote-tracking branches 'odersky/master', 'odersky/topic/capturing' ↵Paul Phillips2012-01-092-1/+34
|\ \ \ | | | | | | | | | | | | and 'szabolcsberecz/xml-attribute-fix'
| | | * Accept prefixed xml attributes with null valueSzabolcs Berecz2012-01-071-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes makes PrefixedAttribute work the same way as UnprefixedAttribute with respect to null values: <t p:a={ null: String }/> is accepted and results in <t/>
| | | * Fixed equality and string representation of xml attributes with null valueSzabolcs Berecz2012-01-072-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this patch <t a={ null: String }/> was not equal to <t/> and it's string representation was "<t ></t>" instead of "<t></t>" This includes changing MetaData.normalize() so that it doesn't reverse the chain. On the downside, the iterate function in MetaData.normalize() is not tail-recursive now.
| * | | Closes SI-5354.Martin Odersky2012-01-042-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | The reason why the test case compiled without error is pretty devious: When checking the `Foo.x' implicit, a CyclicReference error occurs which causes the alternative to be discarded. Why a CylicReference? Because the inferencer tries to decide whether the owner of `z` is a subclass of the owner od `x`. To do this, it computed the info of the owner of `z1`, which is not complete because no result type for `f1` was given. Hence a CyclicReference error. The fix is twofold: (1) We make isNonBottomSubClass smarter so that it always returns false if the symbol in question is not a type; hence the info need not be computed. (2) It's dubious to swallow CyclicReference errors anywhere, but I deemed it too risky to propagate them. But at least the CyclicReference is now logged if -Ylog-implicit is true. This hopefully spares future maintainers the same detective work I had to go through when digging this out.
* | | | Fix for PartialFunction NPE.Paul Phillips2012-01-081-0/+7
| | | | | | | | | | | | | | | | | | | | Was going straight to the field and bypassing the null guard. Closes SI-5300.
* | | | TypeConstraint/TypeVar refinement.Paul Phillips2012-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I zeroed in on the actual conditions under which the parameter bounds can be utilized without poisoning the well. Also fixed a bug in ClassfileParser where it would get confused and set Any as a lower bound, as well as a bug or at least misbehavior where a TypeBounds with only Any/Nothing as an upper/lower bound would be treated differently than one with no bound at all. Review by @moors.
* | | | Made Array manifests return type arguments.Paul Phillips2012-01-071-0/+10
| |_|/ |/| | | | | | | | Closes SI-3758.
* | | Remedy spurious bounds conformance failure.Paul Phillips2012-01-061-0/+19
| | | | | | | | | | | | | | | | | | | | | Misters hkarg and hkparam have to work harder to see things from the same perspective, so they don't end up in a huff over bounds which were the same all along. Closes SI-5020, review by @moors.
* | | Fix for crasher where Arrays meet abstract types.Paul Phillips2012-01-062-0/+21
| | | | | | | | | | | | | | | | | | This sort of thing was crashing. No longer. trait Fooz[Q <: Array[_]] { def f0(x: Q) = x.length }
* | | Fix for crasher during type inference.Paul Phillips2012-01-062-0/+72
| | | | | | | | | | | | | | | Well, "fix" is pretty generous, how about "workaround". It does seem to do the job. Closes SI-4070, review by @moors.
* | | TypeVar tracing.Paul Phillips2012-01-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | % scala -Dscalac.debug.tvar scala> class Foo[CC[X] <: Traversable[X]] { def bar[T](xs: CC[T]) = xs.head } defined class Foo scala> new Foo bar List(1,2,3) [ create] ?CC ( In Foo[CC[X] <: Traversable[X]] ) [ create] ?CC ( In Foo[CC[X] <: Traversable[X]] ) [ setInst] Nothing ( In Foo[CC[X] <: Traversable[X]], CC=Nothing ) [ create] ?CC ( In Foo[CC[X] <: Traversable[X]] ) [ create] ?T ( In Foo[CC[X] <: Traversable[X]]#bar[T] ) [ create] ?A ( In List#apply[A] ) [ create] ?A ( In List#apply[A] ) [ setInst] Int ( In List#apply[A], A=Int ) [ create] ?CC ( In Foo[CC[X] <: Traversable[X]] ) [ create] ?T ( In Foo[CC[X] <: Traversable[X]]#bar[T] ) [ create] ?CC ( In Foo[CC[X] <: Traversable[X]] ) [ applyArgs] ?CC ( In Foo[CC[X] <: Traversable[X]], apply args ?T to CC ) [ setInst] List ( In Foo[CC[X] <: Traversable[X]], CC=List ) [ setInst] Int ( In Foo[CC[X] <: Traversable[X]]#bar[T], T=Int ) res0: Int = 1 Also, I gave TypeVar some polymorphism. Review by @moors.
* | | Error message improvement.Paul Phillips2012-01-052-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | % scalac files/neg/t5357.scala files/neg/t5357.scala:5: error: '=>' expected but ':' found. case A: N => 1 ^ one error found That's uggo! Now it says: % scalac files/neg/t5357.scala files/neg/t5357.scala:5: error: Pattern variables must start with a lower-case letter. (SLS 8.1.1.) case A: N => 1 ^ one error found
* | | Fix issue with higher-order type params.Paul Phillips2012-01-051-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think I found an issue underlying more than one bit of sketchy behavior amongst CC[_] and friends. Plus, I managed to initialize TypeConstraints with the bounds of the originating type parameter. I feel like that should cause something nifty to happen somewhere, but I have seen neither confetti nor lasers in greater quantities than I usually do. Will keep my remaining eye out. Closes SI-5359, review by @moors.
* | | Optimization in refchecks.Paul Phillips2012-01-051-1/+1
| | | | | | | | | | | | Making the inherited java vararg check cheaper.
* | | Optimization in Constructors.Paul Phillips2012-01-051-1/+1
| | | | | | | | | | | | | | | Reworked some old code which was far too expensive for the job it was performing.
* | | Moved Origins into scala.reflect.internal.util.Paul Phillips2012-01-051-1/+1
| | | | | | | | | | | | | | | It's too handy and I can't reach it from key classes whose calls I want to profile.
* | | Don't mark mixed in methods as bridges.Paul Phillips2012-01-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | Sometime during the signature-related chaos before 2.9.1, genjvm was modified to pin ACC_BRIDGE onto mixed-in methods. This isn't necessary to suppress the signature (which has already happened at that point) and has deleterious effects since many tools ignore bridge methods. Review by @odersky.
* | | Fix for NoSuchMethod in cleanup.Paul Phillips2012-01-042-0/+18
| | | | | | | | | | | | | | | | | | Don't assume that just because someone is calling x.toInt and x <: java.lang.Number, that it's a boxed primitive. Closes SI-5356.
* | | Closes SI-5354.Martin Odersky2012-01-042-0/+22
|/ / | | | | | | | | | | The reason why the test case compiled without error is pretty devious: When checking the `Foo.x' implicit, a CyclicReference error occurs which causes the alternative to be discarded. Why a CylicReference? Because the inferencer tries to decide whether the owner of `z` is a subclass of the owner od `x`. To do this, it computed the info of the owner of `z1`, which is not complete because no result type for `f1` was given. Hence a CyclicReference error. The fix is twofold: (1) We make isNonBottomSubClass smarter so that it always returns false if the symbol in question is not a type; hence the info need not be computed. (2) It's dubious to swallow CyclicReference errors anywhere, but I deemed it too risky to propagate them. But at least the CyclicReference is now logged if -Ylog-implicit is true. This hopefully spares future maintainers the same detective work I had to go through when digging this out.
* | Added -Xlog-implicit-conversions.Paul Phillips2012-01-023-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New command line option prints a message whenever the compiler inserts an implicit conversion. Implicit parameters are not under consideration here, since the primary motivation is to make it easy to inspect your code for unintentional conversions, since they can have dramatic performance implications. class A { def f(xs: Array[Byte]) = xs.size def g(xs: Array[Byte]) = xs.length } % scalac -Xlog-implicit-conversions logImplicits.scala logImplicits.scala:2: applied implicit conversion from xs.type to ?{val size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] def f(xs: Array[Byte]) = xs.size ^
* | More uniformity for the parser.Paul Phillips2011-12-311-0/+13
|/ | | | | | | | | | Fixing consecutive type application made it more obvious there was another missing bit of the parser, type application following function application. This should (and now does) work: object F { def apply[T] = List[T]() } def g() = F g()[String]
* More performance work.Paul Phillips2011-12-301-10/+5
| | | | | | | Custom versions of collections which methods which operate on 2 or 3 collections. Eliminated most users of zip/zipped. Cleaned up the kinds checking code somewhat. Reduced the number of silent typechecks being performed at named argument sites.
* Fixing slightly damaged test.Paul Phillips2011-12-281-1/+1
|
* repl power mode improvements.Paul Phillips2011-12-282-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented great suggestion from moors. More imports in power mode, including the contents of treedsl. Also, another swing at overcoming the mismatched global singletons problem, this time taking advantage of dependent method types. Amazingly, it seems to work. Continuing in the quest to create a useful compiler hacking environment, there is now an implicit from Symbol which allows you to pretend a Symbol takes type parameters, and the result is the applied type based on the manifests of the type arguments and the type constructor of the symbol. Examples: // magic with manifests scala> val tp = ArrayClass[scala.util.Random] tp: $r.global.Type = Array[scala.util.Random] // evidence scala> tp.memberType(Array_apply) res0: $r.global.Type = (i: Int)scala.util.Random // treedsl scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) m: $r.treedsl.global.Match = 10 match { case 5 => false case _ => true } // typed is in scope scala> typed(m).tpe res1: $r.treedsl.global.Type = Boolean
* Tone down insensible-equality warning.Paul Phillips2011-12-273-7/+11
| | | | Closes SI-5175.
* Merge branch 'type-currying-mini' of /scala/trunk into developPaul Phillips2011-12-272-0/+72
|\
| * Consecutive type application.Paul Phillips2011-12-272-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | The parser through I think a quirk of history would not allow back to back type applications, like expr[T1, T2][T3, T4] Now it does, meaning the only thing it can: val n0 = Partial[immutable.HashMap][String][Int] ++ Seq(("a", 1)) val n1 = Partial.apply[immutable.HashMap].apply[String].apply[Int] ++ Seq(("a", 1)) assert(n0 == n1)
| |
| \
| \
| \
| \
| \
| \
| \
*-------. \ Merge remote-tracking branches 'ijuma/issue/5341', ↵Paul Phillips2011-12-2723-0/+403
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | | | | | | | | 'kepler/topic/reifyclosuretests', 'kepler/topic/antscalacheck', 'szabolcsberecz/SI-5104', 'kepler/ticket/5334' and 'kepler/topic/miscfixes' into develop
| | | | * | Tests for recently submitted SI-5334Eugene Burmako2011-12-232-0/+30
| | | | |/
| | | * / fixes #5104 and related NaN ordering inconsistenciesSzabolcs Berecz2011-12-251-0/+130
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug was caused by the inconsistency between j.l.Math.min() and j.l.Double.compareTo() wrt NaN (j.l.Math.min() considers NaN to be less than any other value while j.l.Double.compareTo() says it's greater...) The fix changes Ordering.{FloatOrdering,DoubleOrdering) to base it's results on primitive comparisons and math.{min,max} instead of j.l.{Float,Double}.compareTo()
| * | / A handful of tests for closures under reificationEugene Burmako2011-12-2620-0/+243
|/ / /
* / / Fixed regression in lub calculation.Paul Phillips2011-12-261-0/+12
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing NullaryMethodType to be a SimpleTypeProxy because nearly all its operations forward to its result type was it seems not such a good idea, because it also meant that calling .underlying returned the result type rather than the method type. The way this materialized was in subtype checks of refinement types. A lub is calculated for two nullary method types in the course of calculating a refinement, and then the input types are checked against the calculated lub. However in the lub refinement, the nullary method type has become a bare typeref, and so the subtype check failed. Closes SI-5317. This does give me confidence that all the malformed lubs one sees logged under -Ydebug (and there are still many, especially with type constructors) are alerting us to real bugs elsewhere in Types.
* | [vpm] emitting switches -- BodyTreeMakerAdriaan Moors2011-12-245-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) introduce BodyTreeMaker to get rid of special casing for body now each case is a list of TreeMakers rather than a pair of such a list and a tree needed to do this since emitting switches requires access to the untranslated body 2) emitting switches - alternatives are flattened: each alternative block ends with a jump to the next alternative (if there is one) - to avoid stack overflow in typedMatch: detect when translateMatch returns a Match the patch to uncurry would be nicer with an extractor, but that breaks due to a bug in old patmat made trees into dags again -- NPE in erasure tree.duplicate seems to break lambdalift because it does not give fresh symbols (or trees?) to the valdefs for the arguments of duplicated functions duplicate enclosing tree, not subtrees improved propagateSubstitution for AlternativesTreeMaker - it now propagates to all its alternatives, so we don't have to do that in chainBefore - by making propagation more regular, a bug in substitution in AlternativesTreeMaker manifested itself it introduced a new binder, unnecessarily, which then was unbound -- now reusing binder of outer pattern having removeSubstOnly in propagateSubstitution unveiled a bug: guard treemaker should substitute move fixerUpper closer to what it fixes up
* | [vpm] common sub-expression elimination for conditionsAdriaan Moors2011-12-243-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TreeMakers (esp. CondTreeMakers) are approximated by hash-cons'ed Conds sharing is detected for prefixes of Conds, and shared conditions are only tested once their results are stored, and repeated tests branch on the last shared condition, reusing the results from the first time they were checked a Test is 1-to-1 with a TreeMaker, but may share its Cond TODO: clean separation of the two translation strategies: - naive flatMap/orElse (for virtualization) - less-naive if-then-else (with CSE etc coming) sharing trees caused wrong bytecode to be emitted (verifyerror) tentative explanation: "because lambdalift uses mutable state to track which variables have been captured if you refer to the same variable with the same tree twice it'll get confused" Sent at 8:27 PM on Thursday >> grzegorz.kossakowski: so we found a bug in jvm according to http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc2.html checkcast should throw a classcastexception becuase it's a shorthand for if !(x instanceof T) throw ClassCastExcpt but jvm decided to throw verifyerror and yeah, the check is wrong if jvm was not throwing verifyerror it would throw classcast exception saying that ObjectRef cannot be casted to $colon$colon ... >> me: so now where does it come from? since a ref is involved, i thought LambdaLift >> grzegorz.kossakowski: yup or now I don't think lambalift introduces that kind of low-level casts but I might be wrong btw. it's interesting that it unpacks stuff from objectref twice in your code and in one place checkcast is correct and in another is wrong Sent at 9:33 PM on Thursday >> grzegorz.kossakowski: also, since it's a verifyerror I think genjvm should have an assertion >> grzegorz.kossakowski: 193: getfield #54; //Field scala/runtime/ObjectRef.elem:Ljava/lang/Object; 196: checkcast #8; //class scala/runtime/ObjectRef 199: invokevirtual #95; //Method scala/collection/immutable/$colon$colon.tl$1:()Lscala/collection/immutable/List; it's this see you have checkcast for ObjectRef and then on that value, you try to call tl() method from List Sent at 9:56 PM on Thursday >> me: fixed sharing trees is bad very bad because lambdalift uses mutable state to track which variables have been captured if you refer to the same variable with the same tree twice it'll get confused
* | [vpm] unapplyProd: faster matching for case classesAdriaan Moors2011-12-243-0/+28
|/ | | | | | | | | | | | | | | | | | | | | | | | | | behold the mythical unapplyProd: it does not exist, yet it promises to speed up pattern matching on case classes instead of calling the synthetic unapply/unapplySeq, we don't call the mythical synthetic unapplyProd, since -- if it existed -- it would be the identity anyway for case classes eventually, we will allow user-defined unapplyProd's, which should give you almost the same speed as case class matching for user-defined extractors (i.e., you don't have to wrap in an option, just return something on which we can select _i for i = 1 to N, unless it is null, which indicates match failure) still need to figure out a way to derive the types for the subpatterns, without requiring you to wrap your result in a ProductN unapplyProd support for vararg case classes using caseFieldAccessors instead of synthetic _i now the compiler bootstraps again, and after this optimization, quick.lib overhead is 70%, quick.comp is 50% (compiling with a locker built using -Yvirtpatmat, and itself generating code for -Yvirtpatmat) before the optimization, I think the overhead for quick.comp was close to 100% in this scenario more robust tupleSel for case classes TODO: - pos/t602 -- clean up after type inference as in fromCaseClassUnapply - run/pf-catch -- implement new-style orElse for partial function in uncurry
* Omit non-essential TypeApply trees.Eugene Burmako2011-12-222-33/+0
| | | | Otherwise they cause type errors.
* Fix for classOf NPE.Paul Phillips2011-12-192-0/+14
| | | | Let type parameter be inferred. Closes SI-4871.
* Test case closes SI-5119.Paul Phillips2011-12-191-0/+13
|
* Merge remote-tracking branches 'axel22/issue/5293' and ↵Paul Phillips2011-12-1915-140/+307
|\ | | | | | | 'jsuereth/fix-5053-view-unzip' into develop
| * unzip(3) on view now returns view.Josh Suereth2011-12-182-0/+26
| | | | | | | | | | | | | | | | * Added unzip and unzip3 to TraversableViewLike * Added partest tests for unzip on views returning specific collection types. Closes SI-5053 Review by @paulp
| * Fixed "Definition Classes" in bug #5287Vlad Ureche2011-12-165-106/+104
| |
| * Fixed scalacheck test to fail if it's failing.Paul Phillips2011-12-161-7/+1
| |
| * Improve quality of scalacheck range tests input and output.Daniel C. Sobral2011-12-161-26/+55
| | | | | | | | | | | | | | Remove some dead code, activate ByOne generator again, add generators for inclusive ranges, add generators that concentrate on the boundaries, and add some print statements next to exceptions that might get eaten by out of memory errors.
| * Fix for seq/array varargs crasher.Paul Phillips2011-12-131-0/+11
| | | | | | | | Closes SI-4024.
| * Test case closes SI-4063.Paul Phillips2011-12-121-0/+39
| |