From 81437d19c63508ec53370e5244e9d3b128e43be9 Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Thu, 1 Aug 2024 11:22:06 +0100 Subject: [PATCH 1/5] bump scala version, add -experimental scalacOption --- build.sbt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index addec8f4..b31e6861 100644 --- a/build.sbt +++ b/build.sbt @@ -4,11 +4,7 @@ lazy val scalatest = Def.setting("org.scalatest" %%% "scalatest" % "3.2.19") lazy val specs2 = Def.setting("org.specs2" %%% "specs2-core" % "4.20.8") val commonSettings = Defaults.coreDefaultSettings ++ Seq( - /** - * Symbol.newClass is marked experimental, so we should use @experimental annotation in every test suite. - * 3.3.0 has a bug so we can omit this annotation - */ - scalaVersion := "3.3.0", + scalaVersion := "3.3.3", scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-release:8") ) @@ -53,6 +49,7 @@ def crossScalaSettings = { crossScalaVersions := Seq("2.12.20", "2.13.14", scalaVersion.value), Compile / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/main").value, Test / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/test").value, + scalacOptions ++= (if (scalaVersion.value.startsWith("3")) Seq("-experimental") else Nil), libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, _)) => From 62dfe9a48191eb1a1b8129a2a45b1ef81b40a3af Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Thu, 1 Aug 2024 11:24:41 +0100 Subject: [PATCH 2/5] add README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a55b3ee7..c7f5e444 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,9 @@ class JavaClassExtended extends JavaClass val mm = mock[JavaClassExtended] // should be used instead ``` +3. +* Mockito makes use of Symbol.newClass which is marked as experimental; to avoid having to add the `@experimental` + attribute everywhere in tests, you can add the `Test / scalacOptions += "-experimental"` to your build. ## Documentation From ed25358c6b9f3b2bac384c2610f34e72ee4014c6 Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Thu, 1 Aug 2024 11:37:47 +0100 Subject: [PATCH 3/5] only available in 3.4.x --- README.md | 3 ++- build.sbt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7f5e444..d432aab6 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,8 @@ val mm = mock[JavaClassExtended] // should be used instead 3. * Mockito makes use of Symbol.newClass which is marked as experimental; to avoid having to add the `@experimental` - attribute everywhere in tests, you can add the `Test / scalacOptions += "-experimental"` to your build. + attribute everywhere in tests, you can add the `Test / scalacOptions += "-experimental"` to your build. Note + that this option is only available in scala 3.4.0+ ## Documentation diff --git a/build.sbt b/build.sbt index b31e6861..36ea3c3b 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ lazy val scalatest = Def.setting("org.scalatest" %%% "scalatest" % "3.2.19") lazy val specs2 = Def.setting("org.specs2" %%% "specs2-core" % "4.20.8") val commonSettings = Defaults.coreDefaultSettings ++ Seq( - scalaVersion := "3.3.3", + scalaVersion := "3.4.2", scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-release:8") ) From dea2667b569f744f47a63708faee52d520615f9f Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Fri, 2 Aug 2024 12:54:02 +0100 Subject: [PATCH 4/5] fix scala version in github workflow --- .github/workflows/scala.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index a4ba01f5..02f8d5a2 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -47,4 +47,4 @@ jobs: java-version: 11 distribution: 'adopt' - name: Run tests - run: sbt ++3.3.0 test + run: sbt ++3.4.2 test From d087755cb15fd99387b0f45da5154bbb4a83f0b0 Mon Sep 17 00:00:00 2001 From: Hugh Simpson Date: Sat, 21 Sep 2024 10:28:54 +0100 Subject: [PATCH 5/5] rm scala 2 --- .github/workflows/scala.yml | 28 -- build.sbt | 30 +- .../clazz/MockFunctionFinderImpl.scala | 51 --- .../clazz/MockFunctionFinderImpl.scala | 45 --- .../test/mock/ByNameParametersTest.scala | 31 -- .../mock/ByNameParametersTest.scala | 0 .../scala-2/org/scalamock/clazz/Mock.scala | 86 ----- .../scalamock/clazz/MockFunctionFinder.scala | 97 ----- .../org/scalamock/clazz/MockImpl.scala | 193 ---------- .../org/scalamock/clazz/MockMaker.scala | 337 ------------------ .../scalamock/proxy/ProxyMockFactory.scala | 46 --- .../org/scalamock/util/MacroAdapter.scala | 37 -- .../org/scalamock/util/MacroUtils.scala | 88 ----- .../org/scalamock/clazz/Mock.scala | 0 .../scalamock/clazz/MockFunctionFinder.scala | 0 .../org/scalamock/clazz/MockImpl.scala | 0 .../org/scalamock/clazz/MockMaker.scala | 0 .../org/scalamock/clazz/MockType.scala | 0 .../org/scalamock/clazz/Utils.scala | 0 .../scalamock/proxy/ProxyMockFactory.scala | 0 .../PolymorphicTrait.scala | 34 -- .../com.paulbutcher.test/VarSpec.scala | 26 -- .../test/ClassWithContextBoundSpec.scala | 0 .../com/paulbutcher/test/MockTestScala3.scala | 0 .../test/PathDependentParamSpec.scala | 0 .../paulbutcher/test/PolymorphicTrait.scala | 0 .../com/paulbutcher/test/Scala3Spec.scala | 0 .../com/paulbutcher/test/VarSpec.scala | 0 28 files changed, 1 insertion(+), 1128 deletions(-) delete mode 100644 js/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala delete mode 100644 jvm/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala delete mode 100644 jvm/src/test/scala-2/com/paulbutcher/test/mock/ByNameParametersTest.scala rename jvm/src/test/{scala-3 => scala}/mock/ByNameParametersTest.scala (100%) delete mode 100644 shared/src/main/scala-2/org/scalamock/clazz/Mock.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/clazz/MockFunctionFinder.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/clazz/MockImpl.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/clazz/MockMaker.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/proxy/ProxyMockFactory.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/util/MacroAdapter.scala delete mode 100644 shared/src/main/scala-2/org/scalamock/util/MacroUtils.scala rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/Mock.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/MockFunctionFinder.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/MockImpl.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/MockMaker.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/MockType.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/clazz/Utils.scala (100%) rename shared/src/main/{scala-3 => scala}/org/scalamock/proxy/ProxyMockFactory.scala (100%) delete mode 100644 shared/src/test/scala-2/com.paulbutcher.test/PolymorphicTrait.scala delete mode 100644 shared/src/test/scala-2/com.paulbutcher.test/VarSpec.scala rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/ClassWithContextBoundSpec.scala (100%) rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/MockTestScala3.scala (100%) rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/PathDependentParamSpec.scala (100%) rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/PolymorphicTrait.scala (100%) rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/Scala3Spec.scala (100%) rename shared/src/test/{scala-3 => scala}/com/paulbutcher/test/VarSpec.scala (100%) diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index 02f8d5a2..eb1dc355 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -7,34 +7,6 @@ on: branches: [ master ] jobs: - scala_2_12: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: 'adopt' - - name: Run tests - run: sbt ++2.12.18 test - - scala_2_13: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: 'adopt' - - name: Run tests - run: sbt ++2.13.12 test - scala_3: runs-on: ubuntu-latest diff --git a/build.sbt b/build.sbt index 36ea3c3b..94157f0d 100644 --- a/build.sbt +++ b/build.sbt @@ -5,12 +5,11 @@ lazy val specs2 = Def.setting("org.specs2" %%% "specs2-core" % "4.20.8") val commonSettings = Defaults.coreDefaultSettings ++ Seq( scalaVersion := "3.4.2", - scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-release:8") + scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-release:8", "-experimental") ) lazy val scalamock = crossProject(JSPlatform, JVMPlatform) in file(".") settings( commonSettings, - crossScalaSettings, name := "scalamock", Compile / packageBin / publishArtifact := true, Compile / packageDoc / publishArtifact := true, @@ -26,7 +25,6 @@ lazy val scalamock = crossProject(JSPlatform, JVMPlatform) in file(".") settings lazy val examples = project in file("examples") settings( commonSettings, - crossScalaSettings, name := "ScalaMock Examples", publish / skip := true, libraryDependencies ++= Seq( @@ -34,29 +32,3 @@ lazy val examples = project in file("examples") settings( specs2.value % Test ) ) dependsOn scalamock.jvm - -def crossScalaSettings = { - def addDirsByScalaVersion(path: String): Def.Initialize[Seq[sbt.File]] = - scalaVersion.zip(baseDirectory) { case (v, base) => - CrossVersion.partialVersion(v) match { - case Some((v, _)) if Set(2L, 3L).contains(v) => - Seq(base / path / s"scala-$v") - case _ => - Seq.empty - } - } - Seq( - crossScalaVersions := Seq("2.12.20", "2.13.14", scalaVersion.value), - Compile / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/main").value, - Test / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/test").value, - scalacOptions ++= (if (scalaVersion.value.startsWith("3")) Seq("-experimental") else Nil), - libraryDependencies ++= { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, _)) => - Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) - case _ => - Seq.empty - } - } - ) -} \ No newline at end of file diff --git a/js/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala b/js/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala deleted file mode 100644 index efe27baf..00000000 --- a/js/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.util.{MacroAdapter, MacroUtils} - -object MockFunctionFinderImpl { - import MacroAdapter.Context - - // obj.asInstanceOf[js.Dynamic].{name}.asInstanceOf[MockFunctionX[...]] - def mockedFunctionGetter[M: c.WeakTypeTag](c: Context) - (obj: c.Tree, name: c.Name, targs: List[c.Type], actuals: List[c.universe.Type]): c.Expr[M] = { - import c.universe._ - - def mockFunctionName(name: Name, t: Type, targs: List[Type]) = { - val method = t.member(name).asTerm - if (method.isOverloaded) - "mock$" + name + "$" + method.alternatives.indexOf(MockFunctionFinder.resolveOverloaded(c)(method, targs, actuals)) - else - "mock$" + name + "$0" - } - - val fullName = TermName(mockFunctionName(name, obj.tpe, targs)) - - val code = c.Expr[M]( - q"""{ - import scala.scalajs.js - $obj.asInstanceOf[js.Dynamic].$fullName.asInstanceOf[${weakTypeOf[M]}] - }""") - - code - } -} diff --git a/jvm/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala b/jvm/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala deleted file mode 100644 index 4506e678..00000000 --- a/jvm/src/main/scala-2/org/scalamock/clazz/MockFunctionFinderImpl.scala +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.util.MacroAdapter - -object MockFunctionFinderImpl { - import MacroAdapter.Context - - def mockedFunctionGetter[M: c.WeakTypeTag](c: Context) - (obj: c.Tree, name: c.Name, targs: List[c.Type], actuals: List[c.universe.Type]): c.Expr[M] = { - import c.universe._ - - def mockFunctionName(name: Name, t: Type, targs: List[Type]) = { - val method = t.member(name).asTerm - if (method.isOverloaded) - "mock$" + name + "$" + method.alternatives.indexOf(MockFunctionFinder.resolveOverloaded(c)(method, targs, actuals)) - else - "mock$" + name + "$0" - } - - val code = c.Expr[M](q""" - $obj.getClass().getMethod(${mockFunctionName(name, obj.tpe, targs)}).invoke($obj).asInstanceOf[${weakTypeOf[M]}] - """) - code - } -} diff --git a/jvm/src/test/scala-2/com/paulbutcher/test/mock/ByNameParametersTest.scala b/jvm/src/test/scala-2/com/paulbutcher/test/mock/ByNameParametersTest.scala deleted file mode 100644 index fbed5ef1..00000000 --- a/jvm/src/test/scala-2/com/paulbutcher/test/mock/ByNameParametersTest.scala +++ /dev/null @@ -1,31 +0,0 @@ -package com.paulbutcher.test.mock - -import com.paulbutcher.test.TestTrait -import org.scalamock.function.FunctionAdapter1 -import org.scalatest.matchers.should.Matchers -import org.scalamock.scalatest.MockFactory -import org.scalatest.freespec.AnyFreeSpec - -class ByNameParametersTest extends AnyFreeSpec with MockFactory with Matchers { - - autoVerify = false - - "cope with methods with by name parameters" in { - withExpectations { - val m = mock[TestTrait] - (m.byNameParam _).expects(*).returning("it worked") - assertResult("it worked") { m.byNameParam(42) } - } - } - - //! TODO - find a way to make this less ugly - "match methods with by name parameters" in { - withExpectations { - val m = mock[TestTrait] - val f: (=> Int) => Boolean = { x => x == 1 && x == 2 } - ((m.byNameParam _): (=> Int) => String).expects(new FunctionAdapter1(f)).returning("it works") - var y = 0 - assertResult("it works") { m.byNameParam { y += 1; y } } - } - } -} diff --git a/jvm/src/test/scala-3/mock/ByNameParametersTest.scala b/jvm/src/test/scala/mock/ByNameParametersTest.scala similarity index 100% rename from jvm/src/test/scala-3/mock/ByNameParametersTest.scala rename to jvm/src/test/scala/mock/ByNameParametersTest.scala diff --git a/shared/src/main/scala-2/org/scalamock/clazz/Mock.scala b/shared/src/main/scala-2/org/scalamock/clazz/Mock.scala deleted file mode 100644 index b879ba30..00000000 --- a/shared/src/main/scala-2/org/scalamock/clazz/Mock.scala +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.context.MockContext -import org.scalamock.function._ -import org.scalamock.util.Defaultable - -trait Mock { - import scala.language.experimental.macros - import scala.language.implicitConversions - - def mock[T](implicit mockContext: MockContext) : T = macro MockImpl.mock[T] - def stub[T](implicit mockContext: MockContext): T = macro MockImpl.stub[T] - - def mock[T](mockName: String)(implicit mockContext: MockContext) : T = macro MockImpl.mockWithName[T] - def stub[T](mockName: String)(implicit mockContext: MockContext): T = macro MockImpl.stubWithName[T] - - implicit def toMockFunction0[R: Defaultable](f: () => R): MockFunction0[R] = macro MockImpl.toMockFunction0[R] - implicit def toMockFunction1[T1, R: Defaultable](f: T1 => R): MockFunction1[T1, R] = macro MockImpl.toMockFunction1[T1, R] - implicit def toMockFunction2[T1, T2, R: Defaultable](f: (T1, T2) => R): MockFunction2[T1, T2, R] = macro MockImpl.toMockFunction2[T1, T2, R] - implicit def toMockFunction3[T1, T2, T3, R: Defaultable](f: (T1, T2, T3) => R): MockFunction3[T1, T2, T3, R] = macro MockImpl.toMockFunction3[T1, T2, T3, R] - implicit def toMockFunction4[T1, T2, T3, T4, R: Defaultable](f: (T1, T2, T3, T4) => R): MockFunction4[T1, T2, T3, T4, R] = macro MockImpl.toMockFunction4[T1, T2, T3, T4, R] - implicit def toMockFunction5[T1, T2, T3, T4, T5, R: Defaultable](f: (T1, T2, T3, T4, T5) => R): MockFunction5[T1, T2, T3, T4, T5, R] = macro MockImpl.toMockFunction5[T1, T2, T3, T4, T5, R] - implicit def toMockFunction6[T1, T2, T3, T4, T5, T6, R: Defaultable](f: (T1, T2, T3, T4, T5, T6) => R): MockFunction6[T1, T2, T3, T4, T5, T6, R] = macro MockImpl.toMockFunction6[T1, T2, T3, T4, T5, T6, R] - implicit def toMockFunction7[T1, T2, T3, T4, T5, T6, T7, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7) => R): MockFunction7[T1, T2, T3, T4, T5, T6, T7, R] = macro MockImpl.toMockFunction7[T1, T2, T3, T4, T5, T6, T7, R] - implicit def toMockFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8) => R): MockFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R] = macro MockImpl.toMockFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R] - implicit def toMockFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R): MockFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = macro MockImpl.toMockFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] - implicit def toMockFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R): MockFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R] = macro MockImpl.toMockFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R] - implicit def toMockFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R): MockFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R] = macro MockImpl.toMockFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R] - implicit def toMockFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R): MockFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R] = macro MockImpl.toMockFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R] - implicit def toMockFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R): MockFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R] = macro MockImpl.toMockFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R] - implicit def toMockFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R): MockFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R] = macro MockImpl.toMockFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R] - implicit def toMockFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R): MockFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R] = macro MockImpl.toMockFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R] - implicit def toMockFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R): MockFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R] = macro MockImpl.toMockFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R] - implicit def toMockFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R): MockFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] = macro MockImpl.toMockFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] - implicit def toMockFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R): MockFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R] = macro MockImpl.toMockFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R] - implicit def toMockFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R): MockFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R] = macro MockImpl.toMockFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R] - implicit def toMockFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R): MockFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R] = macro MockImpl.toMockFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R] - implicit def toMockFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R): MockFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R] = macro MockImpl.toMockFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R] - implicit def toMockFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R): MockFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R] = macro MockImpl.toMockFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R] - - implicit def toStubFunction0[R: Defaultable](f: () => R): StubFunction0[R] = macro MockImpl.toStubFunction0[R] - implicit def toStubFunction1[T1, R: Defaultable](f: T1 => R): StubFunction1[T1, R] = macro MockImpl.toStubFunction1[T1, R] - implicit def toStubFunction2[T1, T2, R: Defaultable](f: (T1, T2) => R): StubFunction2[T1, T2, R] = macro MockImpl.toStubFunction2[T1, T2, R] - implicit def toStubFunction3[T1, T2, T3, R: Defaultable](f: (T1, T2, T3) => R): StubFunction3[T1, T2, T3, R] = macro MockImpl.toStubFunction3[T1, T2, T3, R] - implicit def toStubFunction4[T1, T2, T3, T4, R: Defaultable](f: (T1, T2, T3, T4) => R): StubFunction4[T1, T2, T3, T4, R] = macro MockImpl.toStubFunction4[T1, T2, T3, T4, R] - implicit def toStubFunction5[T1, T2, T3, T4, T5, R: Defaultable](f: (T1, T2, T3, T4, T5) => R): StubFunction5[T1, T2, T3, T4, T5, R] = macro MockImpl.toStubFunction5[T1, T2, T3, T4, T5, R] - implicit def toStubFunction6[T1, T2, T3, T4, T5, T6, R: Defaultable](f: (T1, T2, T3, T4, T5, T6) => R): StubFunction6[T1, T2, T3, T4, T5, T6, R] = macro MockImpl.toStubFunction6[T1, T2, T3, T4, T5, T6, R] - implicit def toStubFunction7[T1, T2, T3, T4, T5, T6, T7, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7) => R): StubFunction7[T1, T2, T3, T4, T5, T6, T7, R] = macro MockImpl.toStubFunction7[T1, T2, T3, T4, T5, T6, T7, R] - implicit def toStubFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8) => R): StubFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R] = macro MockImpl.toStubFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R] - implicit def toStubFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R): StubFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] = macro MockImpl.toStubFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R] - implicit def toStubFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R): StubFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R] = macro MockImpl.toStubFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R] - implicit def toStubFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R): StubFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R] = macro MockImpl.toStubFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R] - implicit def toStubFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R): StubFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R] = macro MockImpl.toStubFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R] - implicit def toStubFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R): StubFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R] = macro MockImpl.toStubFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R] - implicit def toStubFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R): StubFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R] = macro MockImpl.toStubFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R] - implicit def toStubFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R): StubFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R] = macro MockImpl.toStubFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R] - implicit def toStubFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R): StubFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R] = macro MockImpl.toStubFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R] - implicit def toStubFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R): StubFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] = macro MockImpl.toStubFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] - implicit def toStubFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R): StubFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R] = macro MockImpl.toStubFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R] - implicit def toStubFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R): StubFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R] = macro MockImpl.toStubFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R] - implicit def toStubFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R): StubFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R] = macro MockImpl.toStubFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R] - implicit def toStubFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R): StubFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R] = macro MockImpl.toStubFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R] - implicit def toStubFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R: Defaultable](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R): StubFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R] = macro MockImpl.toStubFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R] -} - - diff --git a/shared/src/main/scala-2/org/scalamock/clazz/MockFunctionFinder.scala b/shared/src/main/scala-2/org/scalamock/clazz/MockFunctionFinder.scala deleted file mode 100644 index d8d8552a..00000000 --- a/shared/src/main/scala-2/org/scalamock/clazz/MockFunctionFinder.scala +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.util.{MacroAdapter, MacroUtils} - -object MockFunctionFinder { - import MacroAdapter.Context - - /** - * Given something of the structure <|o.m _|> where o is a mock object - * and m is a method, find the corresponding MockFunction instance - */ - def findMockFunction[F: c.WeakTypeTag, M: c.WeakTypeTag](c: Context)(f: c.Expr[F], actuals: List[c.universe.Type]): c.Expr[M] = { - import c.universe._ - - val utils = new MacroUtils[c.type](c) - import utils._ - - // todo: JS implementation is needed here - // mock.getClass().getMethod(name).invoke(obj).asInstanceOf[MockFunctionX[...]] - def mockedFunctionGetter(obj: Tree, name: Name, targs: List[Type]): c.Expr[M] = { -// val method = applyOn(applyOn(obj, "getClass"), "getMethod", literal(mockFunctionName(name, obj.tpe, targs))) -// val r = c.Expr[M](castTo(applyOn(method, "invoke", obj), weakTypeOf[M])) - MockFunctionFinderImpl.mockedFunctionGetter[M](c)(obj, name, targs, actuals) - } - - def transcribeTree(tree: Tree, targs: List[Type] = Nil): c.Expr[M] = { - tree match { - case Select(qualifier, name) => mockedFunctionGetter(qualifier, name, targs) - case Block(stats, expr) => c.Expr[M](Block(stats, transcribeTree(expr).tree)) // see issue #62 - case Typed(expr, tpt) => transcribeTree(expr) - case Function(vparams, body) => transcribeTree(body) - case Apply(fun, args) => transcribeTree(fun) - case TypeApply(fun, args) => transcribeTree(fun, args.map(_.tpe)) - case Ident(fun) => reportError(s"please declare '$fun' as MockFunctionx or StubFunctionx (e.g val $fun: MockFunction1[X, R] = ... if it has 1 parameter)") - case _ => reportError( - s"ScalaMock: Unrecognised structure: ${showRaw(tree)}." + - "Please open a ticket at https://github.com/paulbutcher/ScalaMock/issues") - } - } - - transcribeTree(f.tree) - } - - // This performs a ridiculously simple-minded overload resolution, but it works well enough for - // our purposes, and is much easier than trying to backport the implementation that was deleted - // from the macro API (c.f. https://groups.google.com/d/msg/scala-internals/R1iZXfotqds/3xytfX39U2wJ) - //! TODO - replace with official resolveOverloaded if/when it's reinstated - def resolveOverloaded(c: Context)(method: c.universe.TermSymbol, targs: List[c.universe.Type], actuals: List[c.universe.Type]): c.universe.Symbol = { - val utils = new MacroUtils[c.type](c) - import c.universe._ - import utils._ - - def sameTypes(types1: List[Type], types2: List[Type]) = { - // see issue #34 - var these = types1.map(_.dealias) - var those = types2.map(_.dealias) - while (!these.isEmpty && !those.isEmpty && these.head =:= those.head) { - these = these.tail - those = those.tail - } - these.isEmpty && those.isEmpty - } - - method.alternatives find { m => - val tpe = m.typeSignature - val pts = { - if (targs.nonEmpty && tpe.typeParams.length == targs.length) - paramTypes(appliedType(tpe, targs)) - else - paramTypes(tpe) - } - sameTypes(pts, actuals) - } getOrElse { - reportError(s"Unable to resolve overloaded method ${method.name}") - } - } -} diff --git a/shared/src/main/scala-2/org/scalamock/clazz/MockImpl.scala b/shared/src/main/scala-2/org/scalamock/clazz/MockImpl.scala deleted file mode 100644 index a845779c..00000000 --- a/shared/src/main/scala-2/org/scalamock/clazz/MockImpl.scala +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.clazz.MockFunctionFinder.findMockFunction -import org.scalamock.context.MockContext -import org.scalamock.function._ -import org.scalamock.util.{Defaultable, MacroAdapter} - -object MockImpl { - import MacroAdapter.Context - - def mock[T: c.WeakTypeTag](c: Context)(mockContext: c.Expr[MockContext]): c.Expr[T] = { - val maker = MockMaker[T](c)(mockContext, stub = false, mockName = None) - maker.make - } - - def stub[T: c.WeakTypeTag](c: Context)(mockContext: c.Expr[MockContext]): c.Expr[T] = { - val maker = MockMaker[T](c)(mockContext, stub = true, mockName = None) - maker.make - } - - def mockWithName[T: c.WeakTypeTag](c: Context)(mockName: c.Expr[String])(mockContext: c.Expr[MockContext]): c.Expr[T] = { - val maker = MockMaker[T](c)(mockContext, stub = false, mockName = Some(mockName)) - maker.make - } - - def stubWithName[T: c.WeakTypeTag](c: Context)(mockName: c.Expr[String])(mockContext: c.Expr[MockContext]): c.Expr[T] = { - val maker = MockMaker[T](c)(mockContext, stub = true, mockName = Some(mockName)) - maker.make - } - - def MockMaker[T: c.WeakTypeTag](c: Context)(mockContext: c.Expr[MockContext], stub: Boolean, mockName: Option[c.Expr[String]]) = { - val m = new MockMaker[c.type](c) - new m.MockMakerInner[T](mockContext, stub, mockName) - } - - def toMockFunction0[R: c.WeakTypeTag](c: Context)(f: c.Expr[() => R])(evidence$1: c.Expr[Defaultable[R]]) = - findMockFunction[() => R, MockFunction0[R]](c)(f, List()) - - def toMockFunction1[T1: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[T1 => R])(evidence$2: c.Expr[Defaultable[R]]) = - findMockFunction[T1 => R, MockFunction1[T1, R]](c)(f, List(c.weakTypeOf[T1])) - - def toMockFunction2[T1: c.WeakTypeTag, T2: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2) => R])(evidence$3: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2) => R, MockFunction2[T1, T2, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2])) - - def toMockFunction3[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3) => R])(evidence$4: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3) => R, MockFunction3[T1, T2, T3, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3])) - - def toMockFunction4[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4) => R])(evidence$5: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4) => R, MockFunction4[T1, T2, T3, T4, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4])) - - def toMockFunction5[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5) => R])(evidence$6: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5) => R, MockFunction5[T1, T2, T3, T4, T5, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5])) - - def toMockFunction6[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6) => R])(evidence$7: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6) => R, MockFunction6[T1, T2, T3, T4, T5, T6, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6])) - - def toMockFunction7[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7) => R])(evidence$8: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7) => R, MockFunction7[T1, T2, T3, T4, T5, T6, T7, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7])) - - def toMockFunction8[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8) => R])(evidence$9: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8) => R, MockFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8])) - - def toMockFunction9[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R])(evidence$10: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R, MockFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9])) - - def toMockFunction10[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R])(evidence$10: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R, MockFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10])) - - def toMockFunction11[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R])(evidence$11: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R, MockFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11])) - - def toMockFunction12[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R])(evidence$12: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R, MockFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12])) - - def toMockFunction13[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R])(evidence$13: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R, MockFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13])) - - def toMockFunction14[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R])(evidence$14: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R, MockFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14])) - - def toMockFunction15[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R])(evidence$15: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R, MockFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15])) - - def toMockFunction16[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R])(evidence$16: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R, MockFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16])) - - def toMockFunction17[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R])(evidence$17: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R, MockFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17])) - - def toMockFunction18[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R])(evidence$18: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R, MockFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18])) - - def toMockFunction19[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R])(evidence$19: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R, MockFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19])) - - def toMockFunction20[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R])(evidence$20: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R, MockFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20])) - - def toMockFunction21[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, T21: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R])(evidence$21: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R, MockFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20], c.weakTypeOf[T21])) - - def toMockFunction22[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, T21: c.WeakTypeTag, T22: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R])(evidence$22: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R, MockFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20], c.weakTypeOf[T21], c.weakTypeOf[T22])) - - def toStubFunction0[R: c.WeakTypeTag](c: Context)(f: c.Expr[() => R])(evidence$20: c.Expr[Defaultable[R]]) = - findMockFunction[() => R, StubFunction0[R]](c)(f, List()) - - def toStubFunction1[T1: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[T1 => R])(evidence$21: c.Expr[Defaultable[R]]) = - findMockFunction[T1 => R, StubFunction1[T1, R]](c)(f, List(c.weakTypeOf[T1])) - - def toStubFunction2[T1: c.WeakTypeTag, T2: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2) => R])(evidence$22: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2) => R, StubFunction2[T1, T2, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2])) - - def toStubFunction3[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3) => R])(evidence$23: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3) => R, StubFunction3[T1, T2, T3, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3])) - - def toStubFunction4[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4) => R])(evidence$24: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4) => R, StubFunction4[T1, T2, T3, T4, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4])) - - def toStubFunction5[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5) => R])(evidence$25: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5) => R, StubFunction5[T1, T2, T3, T4, T5, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5])) - - def toStubFunction6[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6) => R])(evidence$26: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6) => R, StubFunction6[T1, T2, T3, T4, T5, T6, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6])) - - def toStubFunction7[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7) => R])(evidence$27: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7) => R, StubFunction7[T1, T2, T3, T4, T5, T6, T7, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7])) - - def toStubFunction8[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8) => R])(evidence$28: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8) => R, StubFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8])) - - def toStubFunction9[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R])(evidence$29: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9) => R, StubFunction9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9])) - - def toStubFunction10[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R])(evidence$210: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R, StubFunction10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10])) - - def toStubFunction11[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R])(evidence$211: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) => R, StubFunction11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11])) - - def toStubFunction12[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R])(evidence$212: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) => R, StubFunction12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12])) - - def toStubFunction13[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R])(evidence$213: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) => R, StubFunction13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13])) - - def toStubFunction14[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R])(evidence$214: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) => R, StubFunction14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14])) - - def toStubFunction15[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R])(evidence$215: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) => R, StubFunction15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15])) - - def toStubFunction16[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R])(evidence$216: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) => R, StubFunction16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16])) - - def toStubFunction17[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R])(evidence$217: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) => R, StubFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17])) - - def toStubFunction18[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R])(evidence$218: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) => R, StubFunction18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18])) - - def toStubFunction19[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R])(evidence$219: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) => R, StubFunction19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19])) - - def toStubFunction20[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R])(evidence$220: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) => R, StubFunction20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20])) - - def toStubFunction21[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, T21: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R])(evidence$221: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) => R, StubFunction21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20], c.weakTypeOf[T21])) - - def toStubFunction22[T1: c.WeakTypeTag, T2: c.WeakTypeTag, T3: c.WeakTypeTag, T4: c.WeakTypeTag, T5: c.WeakTypeTag, T6: c.WeakTypeTag, T7: c.WeakTypeTag, T8: c.WeakTypeTag, T9: c.WeakTypeTag, T10: c.WeakTypeTag, T11: c.WeakTypeTag, T12: c.WeakTypeTag, T13: c.WeakTypeTag, T14: c.WeakTypeTag, T15: c.WeakTypeTag, T16: c.WeakTypeTag, T17: c.WeakTypeTag, T18: c.WeakTypeTag, T19: c.WeakTypeTag, T20: c.WeakTypeTag, T21: c.WeakTypeTag, T22: c.WeakTypeTag, R: c.WeakTypeTag](c: Context)(f: c.Expr[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R])(evidence$222: c.Expr[Defaultable[R]]) = - findMockFunction[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) => R, StubFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, R]](c)(f, List(c.weakTypeOf[T1], c.weakTypeOf[T2], c.weakTypeOf[T3], c.weakTypeOf[T4], c.weakTypeOf[T5], c.weakTypeOf[T6], c.weakTypeOf[T7], c.weakTypeOf[T8], c.weakTypeOf[T9], c.weakTypeOf[T10], c.weakTypeOf[T11], c.weakTypeOf[T12], c.weakTypeOf[T13], c.weakTypeOf[T14], c.weakTypeOf[T15], c.weakTypeOf[T16], c.weakTypeOf[T17], c.weakTypeOf[T18], c.weakTypeOf[T19], c.weakTypeOf[T20], c.weakTypeOf[T21], c.weakTypeOf[T22])) -} diff --git a/shared/src/main/scala-2/org/scalamock/clazz/MockMaker.scala b/shared/src/main/scala-2/org/scalamock/clazz/MockMaker.scala deleted file mode 100644 index da1b65e0..00000000 --- a/shared/src/main/scala-2/org/scalamock/clazz/MockMaker.scala +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.clazz - -import org.scalamock.context.MockContext -import org.scalamock.function._ -import org.scalamock.util.MacroAdapter.Context -import org.scalamock.util.{MacroAdapter, MacroUtils} - - -//! TODO - get rid of this nasty two-stage construction when https://issues.scala-lang.org/browse/SI-5521 is fixed -class MockMaker[C <: Context](val ctx: C) { - class MockMakerInner[T: ctx.WeakTypeTag](mockContext: ctx.Expr[MockContext], stub: Boolean, mockName: Option[ctx.Expr[String]]) { - - import ctx.universe._ - import Flag._ - import definitions._ - - import scala.language.reflectiveCalls - - val utils = new MacroUtils[ctx.type](ctx) - - import utils._ - - def mockFunctionClass(paramCount: Int): Type = paramCount match { - case 0 => typeOf[MockFunction0[_]] - case 1 => typeOf[MockFunction1[_, _]] - case 2 => typeOf[MockFunction2[_, _, _]] - case 3 => typeOf[MockFunction3[_, _, _, _]] - case 4 => typeOf[MockFunction4[_, _, _, _, _]] - case 5 => typeOf[MockFunction5[_, _, _, _, _, _]] - case 6 => typeOf[MockFunction6[_, _, _, _, _, _, _]] - case 7 => typeOf[MockFunction7[_, _, _, _, _, _, _, _]] - case 8 => typeOf[MockFunction8[_, _, _, _, _, _, _, _, _]] - case 9 => typeOf[MockFunction9[_, _, _, _, _, _, _, _, _, _]] - case 10 => typeOf[MockFunction10[_, _, _, _, _, _, _, _, _, _, _]] - case 11 => typeOf[MockFunction11[_, _, _, _, _, _, _, _, _, _, _, _]] - case 12 => typeOf[MockFunction12[_, _, _, _, _, _, _, _, _, _, _, _, _]] - case 13 => typeOf[MockFunction13[_, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 14 => typeOf[MockFunction14[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 15 => typeOf[MockFunction15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 16 => typeOf[MockFunction16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 17 => typeOf[MockFunction17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 18 => typeOf[MockFunction18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 19 => typeOf[MockFunction19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 20 => typeOf[MockFunction20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 21 => typeOf[MockFunction21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 22 => typeOf[MockFunction22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case _ => ctx.abort(ctx.enclosingPosition, "ScalaMock: Can't handle methods with more than 22 parameters (yet)") - } - - def stubFunctionClass(paramCount: Int): Type = paramCount match { - case 0 => typeOf[StubFunction0[_]] - case 1 => typeOf[StubFunction1[_, _]] - case 2 => typeOf[StubFunction2[_, _, _]] - case 3 => typeOf[StubFunction3[_, _, _, _]] - case 4 => typeOf[StubFunction4[_, _, _, _, _]] - case 5 => typeOf[StubFunction5[_, _, _, _, _, _]] - case 6 => typeOf[StubFunction6[_, _, _, _, _, _, _]] - case 7 => typeOf[StubFunction7[_, _, _, _, _, _, _, _]] - case 8 => typeOf[StubFunction8[_, _, _, _, _, _, _, _, _]] - case 9 => typeOf[StubFunction9[_, _, _, _, _, _, _, _, _, _]] - case 10 => typeOf[StubFunction10[_, _, _, _, _, _, _, _, _, _, _]] - case 11 => typeOf[StubFunction11[_, _, _, _, _, _, _, _, _, _, _, _]] - case 12 => typeOf[StubFunction12[_, _, _, _, _, _, _, _, _, _, _, _, _]] - case 13 => typeOf[StubFunction13[_, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 14 => typeOf[StubFunction14[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 15 => typeOf[StubFunction15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 16 => typeOf[StubFunction16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 17 => typeOf[StubFunction17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 18 => typeOf[StubFunction18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 19 => typeOf[StubFunction19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 20 => typeOf[StubFunction20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 21 => typeOf[StubFunction21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case 22 => typeOf[StubFunction22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] - case _ => ctx.abort(ctx.enclosingPosition, "ScalaMock: Can't handle methods with more than 22 parameters (yet)") - } - - def classType(paramCount: Int) = if (stub) stubFunctionClass(paramCount) else mockFunctionClass(paramCount) - - def isPathDependentThis(t: Type): Boolean = t match { - case TypeRef(pre, _, _) => isPathDependentThis(pre) - case ThisType(tpe) => tpe == typeToMock.typeSymbol - case _ => false - } - - /** - * Translates forwarder parameters into Trees. - * Also maps Java repeated params into Scala repeated params - */ - def forwarderParamType(t: Type): Tree = t match { - case TypeRef(pre, sym, args) if sym == JavaRepeatedParamClass => - TypeTree(internalTypeRef(pre, RepeatedParamClass, args)) - case TypeRef(pre, sym, args) if isPathDependentThis(t) => - AppliedTypeTree(Ident(TypeName(sym.name.toString)), args map TypeTree _) - case _ => - TypeTree(t) - } - - /** - * Translates mock function parameters into Trees. - * The difference between forwarderParamType is that: - * T* and T... are translated into Seq[T] - * - * see issue #24 - */ - def mockParamType(t: Type): Tree = t match { - case TypeRef(pre, sym, args) if sym == JavaRepeatedParamClass || sym == RepeatedParamClass => - AppliedTypeTree(Ident(typeOf[Seq[_]].typeSymbol), args map TypeTree _) - case TypeRef(pre, sym, args) if isPathDependentThis(t) => - AppliedTypeTree(Ident(TypeName(sym.name.toString)), args map TypeTree _) - case _ => - TypeTree(t) - } - - def methodsNotInObject = - typeToMock.members filter (m => m.isMethod && !isMemberOfObject(m)) map (_.asMethod) - - //! TODO - This is a hack, but it's unclear what it should be instead. See - //! https://groups.google.com/d/topic/scala-user/n11V6_zI5go/discussion - def resolvedType(m: Symbol): Type = - m.typeSignatureIn(internalSuperType(internalThisType(typeToMock.typeSymbol), typeToMock)) - - def buildForwarderParams(methodType: Type) = - paramss(methodType) map { params => - params map { p => - ValDef( - Modifiers(PARAM | (if (p.isImplicit) IMPLICIT else NoFlags)), - TermName(p.name.toString), - forwarderParamType(p.typeSignature), - EmptyTree) - } - } - - // def <|name|>(p1: T1, p2: T2, ...): T = <|mockname|>(p1, p2, ...) - def methodDef(m: MethodSymbol, methodType: Type, body: Tree): DefDef = { - val params = buildForwarderParams(methodType) - DefDef( - Modifiers(OVERRIDE), - m.name, - m.typeParams map { p => internalTypeDef(p) }, - params, - forwarderParamType(finalResultType(methodType)), - body) - } - - def methodImpl(m: MethodSymbol, methodType: Type, body: Tree): DefDef = { - methodType match { - case NullaryMethodType(_) => methodDef(m, methodType, body) - case MethodType(_, _) => methodDef(m, methodType, body) - case PolyType(_, _) => methodDef(m, methodType, body) - case _ => ctx.abort(ctx.enclosingPosition, - s"ScalaMock: Don't know how to handle ${methodType.getClass}. Please open a ticket at https://github.com/paulbutcher/ScalaMock/issues") - } - } - - def forwarderImpl(m: MethodSymbol): ValOrDefDef = { - val mt = resolvedType(m) - if (m.isStable) { - ValDef( - Modifiers(), - TermName(m.name.toString), - TypeTree(mt), - castTo(literal(null), mt)) - } else { - val body = applyListOn( - Select(This(anon), mockFunctionName(m)), "apply", - paramss(mt).flatten map { p => Ident(TermName(p.name.toString)) }) - methodImpl(m, mt, body) - } - } - - def mockFunctionName(m: MethodSymbol) = { - val method = typeToMock.member(m.name).asTerm - val index = method.alternatives.indexOf(m) - assert(index >= 0) - TermName("mock$" + m.name + "$" + index) - } - - // val <|mockname|> = new MockFunctionN[T1, T2, ..., R](mockContext, '<|name|>) - def mockMethod(m: MethodSymbol): ValDef = { - val mt = resolvedType(m) - val clazz = classType(paramCount(mt)) - val types = (paramTypes(mt) map mockParamType _) :+ mockParamType(finalResultType(mt)) - val name = applyOn(scalaSymbol, "apply", mockNameGenerator.generateMockMethodName(m, mt)) - val termName = mockFunctionName(m) - val additionalAnnotations = if(isScalaJs) List(jsExport(termName.encodedName.toString)) else Nil - ValDef( - Modifiers().mapAnnotations(additionalAnnotations ::: _), - mockFunctionName(m), - AppliedTypeTree(Ident(clazz.typeSymbol), types), // see issue #24 - callConstructor( - New(AppliedTypeTree(Ident(clazz.typeSymbol), types)), - mockContext.tree, name - ) - ) - } - - // def () = super.() - def initDef = { - val primaryConstructorOpt = typeToMock.members.collectFirst { - case method: MethodSymbolApi if method.isPrimaryConstructor => method - } - - val constructorArgumentsTypes = primaryConstructorOpt.map { constructor => - val constructorTypeContext = constructor.typeSignatureIn(typeToMock) - val constructorArguments = constructor.paramLists - constructorArguments.map { - symbols => symbols.map(_.typeSignatureIn(constructorTypeContext)) - } - } - - val tnEmpty = TypeName("") // typeNames.EMPTY - val tnConstructor = TermName("") // termNames.CONSTRUCTOR - val superCall: Tree = Select(Super(This(tnEmpty), tnEmpty), tnConstructor) - val constructorCall = constructorArgumentsTypes.fold(Apply(superCall, Nil).asInstanceOf[Tree]) { symbols => - symbols.foldLeft(superCall) { - case (acc, symbol) => Apply(acc, symbol.map(tpe => q"null.asInstanceOf[$tpe]")) - } - } - - DefDef( - Modifiers(), - tnConstructor, - List(), - List(List()), - TypeTree(), - Block( - List(constructorCall), - Literal(Constant(())))) - } - - // new <|typeToMock|> { <|members|> } - def anonClass(members: List[Tree]) = - Block( - List( - ClassDef( - Modifiers(FINAL), - anon, - List(), - Template( - List(TypeTree(typeToMock)), - noSelfType, - initDef +: members))), - callConstructor(New(Ident(anon)))) - - /** - * Class that is responsible for creating mock (and its methods) names so they can be reported on expectations error. - * It either uses mock name specified by user or asks mockContext to generate new one. - */ - class MockNameGenerator() { - private val mockNameValName = TermName("mock$special$mockName") - - /** Member of mock that holds mock name */ - val mockNameVal = { - val mockNameValRhs = { - if (mockName.nonEmpty) { - // new String(mockNameExpr) - callConstructor(New(scalaString), mockName.get.tree) - } else { - // mockContext.generateMockDefaultName(prefix).name - val namePrefix = Literal(Constant(if (stub) "stub" else "mock")) - selectTerm(applyOn(mockContext.tree, "generateMockDefaultName", namePrefix), "name") - } - } - // val mock$special$mockName = ... - ValDef(Modifiers(), mockNameValName, TypeTree(), mockNameValRhs) - } - - def generateMockMethodName(method: MethodSymbol, methodType: Type): Tree = { - val mockType: Type = typeToMock.resultType - val mockTypeNamePart: String = mockType.typeSymbol.name.toString - val mockTypeArgsPart: String = generateTypeArgsString(mockType.typeArgs) - val objectNamePart: Tree = Select(This(anon), mockNameValName) - - val methodTypeParamsPart: String = generateTypeArgsString(methodType.typeParams map (_.name)) - val methodNamePart: String = method.name.toString - - // "<%s> %s%s.%s".format(objectNamePart, mockTypeNamePart, mockTypeArgsPart, methodNamePart, methodTypeParamsPart) - val formatStr = applyOn(scalaPredef, "augmentString", literal("<%s> %s%s.%s%s")) - applyOn(formatStr, "format", - objectNamePart, literal(mockTypeNamePart), literal(mockTypeArgsPart), literal(methodNamePart), literal(methodTypeParamsPart)) - } - - private def generateTypeArgsString(typeArgs: List[Any]): String = { - if (typeArgs.nonEmpty) - "[%s]".format(typeArgs.mkString(",")) - else "" - } - } - - val mockNameGenerator = new MockNameGenerator() - val typeToMock = weakTypeOf[T] - val anon = TypeName("$anon") - val methodsToMock = methodsNotInObject.filter { m => - !m.isConstructor && !m.isPrivate && m.privateWithin == NoSymbol && - !m.isFinal && - !m.asInstanceOf[reflect.internal.HasFlags].hasFlag(reflect.internal.Flags.BRIDGE) && - !m.isParamWithDefault && // see issue #43 - (!(m.isStable || m.isAccessor) || - m.asInstanceOf[reflect.internal.HasFlags].isDeferred) //! TODO - stop using internal if/when this gets into the API - }.toList - val forwarders = methodsToMock map forwarderImpl - val mocks = methodsToMock map mockMethod - val members = mockNameGenerator.mockNameVal :: forwarders ++ mocks - - def make = { - val result = castTo(anonClass(members), typeToMock) - - // println("------------") - // println(showRaw(result)) - // println("------------") - // println(show(result)) - // println("------------") - - ctx.Expr(result) - } - } -} diff --git a/shared/src/main/scala-2/org/scalamock/proxy/ProxyMockFactory.scala b/shared/src/main/scala-2/org/scalamock/proxy/ProxyMockFactory.scala deleted file mode 100644 index 1a1538b6..00000000 --- a/shared/src/main/scala-2/org/scalamock/proxy/ProxyMockFactory.scala +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.proxy - -import java.lang.reflect.{InvocationHandler, Proxy => JavaProxy} -import org.scalamock.context.MockContext - -import scala.reflect.{ClassTag, classTag} - -trait ProxyMockFactory { - - protected def mock[T : ClassTag](implicit mockContext: MockContext) = - createProxy[T, Mock](new MockInvocationHandler(mockContext)) - - protected def stub[T : ClassTag](implicit mockContext: MockContext) = - createProxy[T, Stub](new StubInvocationHandler(mockContext)) - - private def createProxy[T : ClassTag, F : ClassTag](handler: InvocationHandler) = { - val classLoader = Thread.currentThread.getContextClassLoader - val interfaces = Array[Class[_]](classTag[T].runtimeClass, classTag[F].runtimeClass) - try { - JavaProxy.newProxyInstance(classLoader, interfaces, handler).asInstanceOf[T with F] - } catch { - case e: IllegalArgumentException => - throw new IllegalArgumentException("Unable to create proxy - possible classloader issue?", e) - } - } -} \ No newline at end of file diff --git a/shared/src/main/scala-2/org/scalamock/util/MacroAdapter.scala b/shared/src/main/scala-2/org/scalamock/util/MacroAdapter.scala deleted file mode 100644 index 5615d6e4..00000000 --- a/shared/src/main/scala-2/org/scalamock/util/MacroAdapter.scala +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2011-2017 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.util - -trait MacroAdapter { - - protected val ctx: MacroAdapter.Context - import ctx.universe._ - - def freshTerm(prefix: String): TermName = ctx.freshName(TermName(prefix)) - def internalTypeRef(pre: Type, sym: Symbol, args: List[Type]) = internal.typeRef(pre, sym, args) - def internalSuperType(thistpe: Type, supertpe: Type): Type = internal.superType(thistpe, supertpe) - def internalThisType(thistpe: Symbol) = internal.thisType(thistpe) - def internalTypeDef(p: Symbol): TypeDef = internal.typeDef(p) -} - -object MacroAdapter { - type Context = scala.reflect.macros.blackbox.Context -} diff --git a/shared/src/main/scala-2/org/scalamock/util/MacroUtils.scala b/shared/src/main/scala-2/org/scalamock/util/MacroUtils.scala deleted file mode 100644 index 05a59d5b..00000000 --- a/shared/src/main/scala-2/org/scalamock/util/MacroUtils.scala +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package org.scalamock.util - -import org.scalamock.util.MacroAdapter.Context - -/** - * Helper functions to work with Scala macros and to create scala.reflect Trees. - */ -private[scalamock] class MacroUtils[C <: Context](protected val ctx: C) extends MacroAdapter { - import ctx.universe._ - - final lazy val isScalaJs = - ctx.compilerSettings.exists(o => o.startsWith("-Xplugin:") && o.contains("scalajs-compiler")) - - def jsExport(name: String) = q"new _root_.scala.scalajs.js.annotation.JSExport($name)" - - // Convert a methodType into its ultimate result type - // For nullary and normal methods, this is just the result type - // For curried methods, this is the final result type of the result type - def finalResultType(methodType: Type): Type = methodType match { - case NullaryMethodType(result) => result - case MethodType(_, result) => finalResultType(result) - case PolyType(_, result) => finalResultType(result) - case _ => methodType - } - - // Convert a methodType into a list of lists of params: - // UnaryMethodType => Nil - // Normal method => List(List(p1, p2, ...)) - // Curried method => List(List(p1, p2, ...), List(q1, q2, ...), ...) - def paramss(methodType: Type): List[List[Symbol]] = methodType match { - case MethodType(params, result) => params :: paramss(result) - case PolyType(_, result) => paramss(result) - case _ => Nil - } - - def paramCount(methodType: Type): Int = methodType match { - case MethodType(params, result) => params.length + paramCount(result) - case PolyType(_, result) => paramCount(result) - case _ => 0 - } - - def paramTypes(methodType: Type): List[Type] = paramss(methodType).flatten map { _.typeSignature } - - def isMemberOfObject(s: Symbol) = { - val res = TypeTag.Object.tpe.member(s.name) - res != NoSymbol && res.typeSignature == s.typeSignature - } - - // <|expr|>.asInstanceOf[<|t|>] - def castTo(expr: Tree, t: Type): Tree = TypeApply(selectTerm(expr, "asInstanceOf"), List(TypeTree(t))) - - val scalaPredef: Tree = selectTerm(Ident(TermName("scala")), "Predef") - val scalaSymbol: Tree = selectTerm(Ident(TermName("scala")), "Symbol") - val scalaString: Tree = Select(scalaPredef, TypeName("String")) - - def literal(str: String): Literal = Literal(Constant(str)) - def selectTerm(qualifier: Tree, name: String): Tree = Select(qualifier, TermName(name)) - def applyListOn(qualifier: Tree, name: String, args: List[Tree]): Tree = Apply(selectTerm(qualifier, name), args) - def applyOn(qualifier: Tree, name: String, args: Tree*): Tree = applyListOn(qualifier, name, args.toList) - def callConstructor(obj: Tree, args: Tree*): Tree = Apply(selectTerm(obj, ""), args.toList) - - def reportError(message: String) = { - // Report with both info and abort so that the user still sees something, even if this is within an - // implicit conversion (see https://issues.scala-lang.org/browse/SI-5902) - ctx.info(ctx.enclosingPosition, message, true) - ctx.abort(ctx.enclosingPosition, message) - } -} diff --git a/shared/src/main/scala-3/org/scalamock/clazz/Mock.scala b/shared/src/main/scala/org/scalamock/clazz/Mock.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/Mock.scala rename to shared/src/main/scala/org/scalamock/clazz/Mock.scala diff --git a/shared/src/main/scala-3/org/scalamock/clazz/MockFunctionFinder.scala b/shared/src/main/scala/org/scalamock/clazz/MockFunctionFinder.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/MockFunctionFinder.scala rename to shared/src/main/scala/org/scalamock/clazz/MockFunctionFinder.scala diff --git a/shared/src/main/scala-3/org/scalamock/clazz/MockImpl.scala b/shared/src/main/scala/org/scalamock/clazz/MockImpl.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/MockImpl.scala rename to shared/src/main/scala/org/scalamock/clazz/MockImpl.scala diff --git a/shared/src/main/scala-3/org/scalamock/clazz/MockMaker.scala b/shared/src/main/scala/org/scalamock/clazz/MockMaker.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/MockMaker.scala rename to shared/src/main/scala/org/scalamock/clazz/MockMaker.scala diff --git a/shared/src/main/scala-3/org/scalamock/clazz/MockType.scala b/shared/src/main/scala/org/scalamock/clazz/MockType.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/MockType.scala rename to shared/src/main/scala/org/scalamock/clazz/MockType.scala diff --git a/shared/src/main/scala-3/org/scalamock/clazz/Utils.scala b/shared/src/main/scala/org/scalamock/clazz/Utils.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/clazz/Utils.scala rename to shared/src/main/scala/org/scalamock/clazz/Utils.scala diff --git a/shared/src/main/scala-3/org/scalamock/proxy/ProxyMockFactory.scala b/shared/src/main/scala/org/scalamock/proxy/ProxyMockFactory.scala similarity index 100% rename from shared/src/main/scala-3/org/scalamock/proxy/ProxyMockFactory.scala rename to shared/src/main/scala/org/scalamock/proxy/ProxyMockFactory.scala diff --git a/shared/src/test/scala-2/com.paulbutcher.test/PolymorphicTrait.scala b/shared/src/test/scala-2/com.paulbutcher.test/PolymorphicTrait.scala deleted file mode 100644 index 24c7dbaa..00000000 --- a/shared/src/test/scala-2/com.paulbutcher.test/PolymorphicTrait.scala +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011-2015 ScalaMock Contributors (https://github.com/paulbutcher/ScalaMock/graphs/contributors) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package com.paulbutcher.test - -trait PolymorphicTrait[T] { - def method[U](x: Int, y: T, z: U): T - - trait Embedded[V] { - trait ATrait[A, B] - - def innerTrait(t: T, v: V): ATrait[T, V] - def outerTrait(t: T, v: V): PolymorphicTrait.this.ATrait[T, V] - } - - trait ATrait[A, B] -} \ No newline at end of file diff --git a/shared/src/test/scala-2/com.paulbutcher.test/VarSpec.scala b/shared/src/test/scala-2/com.paulbutcher.test/VarSpec.scala deleted file mode 100644 index ad61b0ca..00000000 --- a/shared/src/test/scala-2/com.paulbutcher.test/VarSpec.scala +++ /dev/null @@ -1,26 +0,0 @@ -package com.paulbutcher.test - -import org.scalamock.scalatest.MockFactory -import org.scalatest.funspec.AnyFunSpec - -class VarSpec extends AnyFunSpec with MockFactory { - - autoVerify = false - - trait Vars { - var aVar: String - var concreteVar = "foo" - } - - it("mock traits with vars") { - withExpectations { - val m = mock[Vars] - (m.aVar_= _).expects("foo") - (() => m.aVar).expects().returning("bar") - m.aVar = "foo" - assertResult("bar") { - m.aVar - } - } - } -} \ No newline at end of file diff --git a/shared/src/test/scala-3/com/paulbutcher/test/ClassWithContextBoundSpec.scala b/shared/src/test/scala/com/paulbutcher/test/ClassWithContextBoundSpec.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/ClassWithContextBoundSpec.scala rename to shared/src/test/scala/com/paulbutcher/test/ClassWithContextBoundSpec.scala diff --git a/shared/src/test/scala-3/com/paulbutcher/test/MockTestScala3.scala b/shared/src/test/scala/com/paulbutcher/test/MockTestScala3.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/MockTestScala3.scala rename to shared/src/test/scala/com/paulbutcher/test/MockTestScala3.scala diff --git a/shared/src/test/scala-3/com/paulbutcher/test/PathDependentParamSpec.scala b/shared/src/test/scala/com/paulbutcher/test/PathDependentParamSpec.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/PathDependentParamSpec.scala rename to shared/src/test/scala/com/paulbutcher/test/PathDependentParamSpec.scala diff --git a/shared/src/test/scala-3/com/paulbutcher/test/PolymorphicTrait.scala b/shared/src/test/scala/com/paulbutcher/test/PolymorphicTrait.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/PolymorphicTrait.scala rename to shared/src/test/scala/com/paulbutcher/test/PolymorphicTrait.scala diff --git a/shared/src/test/scala-3/com/paulbutcher/test/Scala3Spec.scala b/shared/src/test/scala/com/paulbutcher/test/Scala3Spec.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/Scala3Spec.scala rename to shared/src/test/scala/com/paulbutcher/test/Scala3Spec.scala diff --git a/shared/src/test/scala-3/com/paulbutcher/test/VarSpec.scala b/shared/src/test/scala/com/paulbutcher/test/VarSpec.scala similarity index 100% rename from shared/src/test/scala-3/com/paulbutcher/test/VarSpec.scala rename to shared/src/test/scala/com/paulbutcher/test/VarSpec.scala