| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
^
|
|
|
|
|
|
|
|
|
|
| |
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]
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Closes SI-5175.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| | | |
| \ | |
| \ | |
| \ | |
| \ | |
| \ | |
| \ | |
| \ | |
|\ \ \ \ \ \
| |_|_|_|_|/
|/| | | | |
| | | | | | |
'kepler/topic/reifyclosuretests', 'kepler/topic/antscalacheck', 'szabolcsberecz/SI-5104', 'kepler/ticket/5334' and 'kepler/topic/miscfixes' into develop
|
| | | | |/ |
|
| | | |/
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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()
|
|/ / / |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Otherwise they cause type errors.
|
|
|
|
| |
Let type parameter be inferred. Closes SI-4871.
|
| |
|
|\
| |
| |
| | |
'jsuereth/fix-5053-view-unzip' into develop
|
| |
| |
| |
| |
| |
| |
| |
| | |
* Added unzip and unzip3 to TraversableViewLike
* Added partest tests for unzip on views returning specific collection types.
Closes SI-5053
Review by @paulp
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Closes SI-4024.
|
| | |
|
| | |
|
| |\ |
|
| | |\ \ \
| | | | | |
| | | | | |
| | | | | | |
'kepler/ticket/5295' and 'blair/clarify-Map-withDefaultValue' into develop
|
| | | |/ /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Usually scripts like scala.bat and scalac.bat correctly propagate
exit codes from underlying Java invocations. However, if you run these
scripts as follows: "cmd /c scala ...", then errorlevel gets swallowed.
This simple patch fixes the aforementioned problem.
Fixes SI-5295, no review.
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This makes code like
0 to 100 foreach (x += _)
as fast as (often faster than, in fact) a while loop. See the
comment in Range for the gory details. More investigation should
be done regarding total impact on inlining behavior.
Review by @odersky.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The hash code is further improved by using a special value in the hash sets
called a `seed`. For sequential hash tables, this value depends on the size
of the hash table. It determines the number of bits the hashcode should be
rotated. This ensures that hash tables with different sizes use different
bits to compute the position of the element. This way traversing the elements
of the source hash table will yield them in the order where they had similar
hashcodes (and hence, positions) in the source table, but different ones in
the destination table.
Ideally, in the future we want to be able to have a family of hash functions
and assign a different hash function from that family to each hash table
instance. That would statistically almost completely eliminate the possibility
that the hash table element traversal causes excessive collisions.
I should probably @mention extempore here.
|
|/ /
| |
| |
| |
| |
| | |
It foiled me right on the cusp of a successful windows nightly.
https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-windows/1170/consoleText
|
|\|
| |
| |
| | |
'jsuereth/dont_resolve_releases'
|
| |\ \
| | | |
| | | |
| | | | |
'fedgehog/docs_fix_for_scala.Either.cond___SI-5113' and 'kepler/ticket/5266' into develop
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Wrapper method for AST undergoing a reflective compilation
has been incorrectly marked as static.
This was off the radars until one day the code being compiled declared
a top-level method. During flatten that method got hoisted into the
wrapper module, and its invocation got translated into an instance
call upon the module. This led to static wrapper method trying to call
an instance method, and that blew up the bytecode verifier. More info:
https://issues.scala-lang.org/browse/SI-5266.
Fixes SI-5266, review by @odersky.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The @migration annotation can now be used like @deprecation.
Old syntax is still supported, but deprecated.
Improve wording and consistency of migration messages, migration
warnings also print the version in which the change occurred now.
Partially fixes SI-4990.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The documents with use cases should be restructured like:
/**
* The full definition, either used with an implicit value or with an explicit one.
*
* Some more explanation on implicits...
*
* @param lost a lost parameter
* @return some integer
*
* @usecase def test(): Int
*
* This takes the implicit value in scope.
*
* Example: `test()`
*
* @usecase def test(explicit: Int): Int
*
* This takes the explicit value passed.
*
* Example: `test(3)`
*/
def test(implicit lost: Int): Int
|
|\ |
|
| | |
|
|\ \
| | |
| | |
| | | |
'blair/remove-documentation-stutters' into develop
|
| | | |
|
|/ / |
|
| |
| |
| |
| |
| |
| | |
Everyone's favorite "will they or won't they" tests, akka and timeofday.
They will be welcomed back into the fold once they can stick to a
decision on whether to pass or fail.
|
| |
| |
| |
| | |
Also see https://github.com/scala/scala/pull/25.
|
|\ \ |
|
| | | |
|
| | | | |
| \ \ | |
|\ \ \ \
| | | | |
| | | | |
| | | | | |
'ijuma/feature/signum' into develop
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The Java implementation is faster as it doesn't have branches.
java.lang.Math includes implementations of signum for Double and Float,
but I didn't change the ones in scala.math because there is a difference
on how negative zero is handled.
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Multiple minor fixes to Martin's implementation of reflection infrastructure.
Dominating theme is allowing for the fact that compilation via reflection
involves numerous exports/imports between various reflection universes.
Fixes SI-5230. Review by @odersky.
|