Skip to content

Instantly share code, notes, and snippets.

View DarkDimius's full-sized avatar

Dmitry Petrashko DarkDimius

View GitHub Profile
class X {
private def foo = 1
}
object X {
class Inner extends X {
override private def foo = 2
}
}
14:48 14:47 ~/Projects/211x/sandbox (2.11.x)$ s
@DarkDimius
DarkDimius / 214.scala
Last active October 5, 2015 11:58
How many Iterables are there in stdlib?
214.
http://www.scala-lang.org/api/current/index.html#scala.collection.Iterable
// if name is listed twice - most likely one is mutable and the other is immutable
::, AbstractBuffer, AbstractIterable, AbstractIterable, AbstractMap, AbstractMap,
AbstractMap, AbstractSeq, AbstractSeq, AbstractSet, AbstractSet, AnyRefMap,
Appended, Appended, Appended, ArrayBuffer, ArraySeq, ArrayStack, BitSet, BitSet,
BitSet, BitSet1, BitSet2, BitSetN, Buffer, BufferProxy, Cons, DefaultKeySet,
Software Grant and Individual Contributor License Agreement ("Agreement"), v1.0
In order to clarify the intellectual property license granted with Contributions from any person or entity, EPFL must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of EPFL; it does not change your rights to use your own Contributions for any other purpose.
Please read this document carefully before signing and keep a copy for your records.
You accept and agree to the following terms and conditions for your present and future Contributions submitted to EPFL. Except for the license granted herein to EPFL and recipients of software distributed by EPFL, You reserve all right, title, and interest in and to Your Contributions.
1. Definitions.
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this
@DarkDimius
DarkDimius / 1.Inheritance.scala
Last active April 19, 2017 08:53
Reachability examples
trait A {/* has a `def toString: String` inherited from scala.Any */}
class B extends A { override def toString = "B"}
class C extends A { override def toString = "C" /* is this dead code? */ }
def main(a: Array[String]): Unit = {
def foo(a: A) = a.toString // does it call .toString on all the A’s?
val b: B = new B;
val c: C = new C;
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000010779a603, pid=87348, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V [libjvm.dylib+0x39a603] klassItable::initialize_itable_for_interface(int, KlassHandle, bool, Thread*)+0x3f
#
diff --git a/src/scala/compat/java8/JFunction1$mcII$sp.java b/src/scala/compat/java8/JFunction1$mcII$sp.java
index 14fce8a..56eb652 100644
--- a/src/scala/compat/java8/JFunction1$mcII$sp.java
+++ b/src/scala/compat/java8/JFunction1$mcII$sp.java
@@ -5,9 +5,17 @@
package scala.compat.java8;
+import dotty.runtime.vc.VCIntPrototype;
+
case class CC(a: Int, b: Object)
object Lists{
def foo(x: Any): Int = {
val (a, b) = x match {
case CC(s @ 1, CC(t, _)) =>
(s , 2)
case _ => (42, 43)
}
a + b
}
dark@tsf-452-wpa-3-234 ~/workspace/dotty/src/dotty/tools/dotc (opto) $ timed-bootstrap-bench-classes
typer/RefChecks.scala:68: warning: match may not be exhaustive.
It would fail on the following input: (_, _)
for ((_, m1 :: m2 :: _) <- (clazz.info member nme.applyDynamic).alternatives groupBy (_.symbol.typeParams.length)) {
^
one warning found
there were 4 deprecation warning(s); re-run with -deprecation for details
time elapsed: 29438ms
one warning found
there were 4 deprecation warning(s); re-run with -deprecation for details
object unsoundForwardRef {
trait LowerBound[T] {
type M >: T;
}
trait UpperBound[U] {
type M <: U;
}
val bounded1 : LowerBound[Int] with UpperBound[String] = hideForwardRef
Exception in thread "main" java.lang.AssertionError: assertion failed: module HashSet
at scala.Predef$.assert(Predef.scala:165)
at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:319)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:470)
at dotty.tools.dotc.core.tasty.TreePickler$$anonfun$pickleTree$15$$anonfun$apply$mcV$sp$9.apply(TreePickler.scala:450)
at dotty.tools.dotc.core.tasty.TreePickler$$anonfun$pickleTree$15$$anonfun$apply$mcV$sp$9.apply(TreePickler.scala:450)
at scala.collection.immutable.List.foreach(List.scala:381)
at dotty.tools.dotc.core.tasty.TreePickler$$anonfun$pickleTree$15.apply$mcV$sp(TreePickler.scala:450)
at dotty.tools.dotc.core.tasty.TreePickler.dotty$tools$dotc$core$tasty$TreePickler$$withLength(TreePickler.scala:29)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:450)