Add an Expression type, which is a tuple of a CodeBlock and the type that it represents. This will help implementing BindingExpressions for @Binds methods, in particular for the following case:

@Binds Foo to(FooImpl impl);

where Foo is public but FooImpl is not, nor is it in the same package as the component. If FooImpl is scoped, a rawtypes Provider will be used. Before this change, the BindingExpression for Foo had no way of knowing if the FooImpl it was receiving was in fact a FooImpl or an Object from the perspective of the compiler.

This should also hopefully simplify some of the logic in SimpleMethodBindingExpression and InjectionMethods where casting is needed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170374236
diff --git a/java/dagger/internal/codegen/MapBindingExpression.java b/java/dagger/internal/codegen/MapBindingExpression.java
index eba9511..165d695 100644
--- a/java/dagger/internal/codegen/MapBindingExpression.java
+++ b/java/dagger/internal/codegen/MapBindingExpression.java
@@ -32,6 +32,7 @@
 import java.util.Map;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
 
 /** A {@link BindingExpression} for multibound maps. */
 final class MapBindingExpression extends SimpleInvocationBindingExpression {
@@ -48,8 +49,9 @@
       BindingGraph graph,
       ComponentBindingExpressions componentBindingExpressions,
       BindingExpression delegate,
+      Types types,
       Elements elements) {
-    super(delegate);
+    super(delegate, types, elements);
     ContributionBinding.Kind bindingKind = binding.bindingKind();
     checkArgument(bindingKind.equals(SYNTHETIC_MULTIBOUND_MAP), bindingKind);
     this.binding = binding;
@@ -62,8 +64,12 @@
   }
 
   @Override
-  CodeBlock getInstanceDependencyExpression(
+  Expression getInstanceDependencyExpression(
       DependencyRequest.Kind requestKind, ClassName requestingClass) {
+    return Expression.create(binding.key().type(), mapExpression(requestingClass));
+  }
+
+  private CodeBlock mapExpression(ClassName requestingClass) {
     // TODO(ronshapiro): We should also make an ImmutableMap version of MapFactory
     boolean isImmutableMapAvailable = isImmutableMapAvailable();
     // TODO(ronshapiro, gak): Use Maps.immutableEnumMap() if it's available?
@@ -111,7 +117,9 @@
     return CodeBlock.of(
         "$L, $L",
         getMapKeyExpression(dependencies.get(dependency), requestingClass),
-        componentBindingExpressions.getDependencyExpression(dependency, requestingClass));
+        componentBindingExpressions
+            .getDependencyExpression(dependency, requestingClass)
+            .codeBlock());
   }
 
   private CodeBlock collectionsStaticFactoryInvocation(