Repository: TypeScript
Issue: Accessing protected properties with `this` argument specifier differs with interface
Labels: Bug

<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section!

Please help us by doing the following steps before logging an issue:
  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues
  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ

Please fill in the *entire* template below.
-->

<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->
**TypeScript Version:**  3.2.2

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**
function this parameter class interface protected property
**Code**

```ts
abstract class Test {
    constructor(protected foo: string) {}
    public abstract trace(): string;
}

function TraceA(this: Test): string {
    return `${this.foo}`;
}

function TraceB(this: Test): string {
    return `<pre>${this.foo}</pre>`;
}

function getTestInstance(strategy: 'A' | 'B') {
    return class StrategyTest extends Test {
        public trace = strategy === 'A' ? TraceA : TraceB;
    }
}
```

```ts
abstract class TestInterface<P> {
    constructor(protected foo: P) {}
    public abstract trace(): string;
}

function TraceInterfaceA<P>(this: TestInterface<P>): string {
    return `${this.foo}`; // Property 'foo' is protected and only accessible through an instance of class 'TestInterface<P>'.ts(2446)
}

function TraceInterfaceB<P>(this: TestInterface<P>): string {
    return `<pre>${this.foo}</pre>`; // Property 'foo' is protected and only accessible through an instance of class 'TestInterface<P>'.ts(2446)
}

function getTestInterfaceInstance(strategy: 'A' | 'B') {
    return class StrategyTestInterface<P> extends TestInterface<P> {
        public trace = strategy === 'A' ? TraceA : TraceB;
    }
}

```

**Expected behavior:**
If I'm not wrong, with `this` argument on `Function`, we allow only to access to public attributes, don't we? So we are supposed to get an error on the `Test` class implementation.
Or if the latest decision is to allow access to protected attributes, so we aren't supposed to received an error in the `TestInterface` example.
**Actual behavior:**
Without the interface, we can access to protected attributes, but when an interface is provided to the generic Class definition, we lose the ability to reach protected properties. 

**Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->
[TSPlayground](https://www.typescriptlang.org/play/#src=abstract%20class%20Test%20%7B%0D%0A%20%20%20%20constructor(protected%20foo%3A%20string)%20%7B%7D%0D%0A%20%20%20%20public%20abstract%20trace()%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Afunction%20TraceA(this%3A%20Test)%3A%20string%20%7B%0D%0A%20%20%20%20return%20%60%24%7Bthis.foo%7D%60%3B%0D%0A%7D%0D%0A%0D%0Afunction%20TraceB(this%3A%20Test)%3A%20string%20%7B%0D%0A%20%20%20%20return%20%60%3Cpre%3E%24%7Bthis.foo%7D%3C%2Fpre%3E%60%3B%0D%0A%7D%0D%0A%0D%0Afunction%20getTestInstance(strategy%3A%20'A'%20%7C%20'B')%20%7B%0D%0A%20%20%20%20return%20class%20StrategyTest%20extends%20Test%20%7B%0D%0A%20%20%20%20%20%20%20%20public%20trace%20%3D%20strategy%20%3D%3D%3D%20'A'%20%3F%20TraceA%20%3A%20TraceB%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%0D%0A%0D%0Aabstract%20class%20TestInterface%3CP%3E%20%7B%0D%0A%20%20%20%20constructor(protected%20foo%3A%20P)%20%7B%7D%0D%0A%20%20%20%20public%20abstract%20trace()%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Afunction%20TraceInterfaceA%3CP%3E(this%3A%20TestInterface%3CP%3E)%3A%20string%20%7B%0D%0A%20%20%20%20return%20%60%24%7Bthis.foo%7D%60%3B%0D%0A%7D%0D%0A%0D%0Afunction%20TraceInterfaceB%3CP%3E(this%3A%20TestInterface%3CP%3E)%3A%20string%20%7B%0D%0A%20%20%20%20return%20%60%3Cpre%3E%24%7Bthis.foo%7D%3C%2Fpre%3E%60%3B%0D%0A%7D%0D%0A%0D%0Afunction%20getTestInterfaceInstance(strategy%3A%20'A'%20%7C%20'B')%20%7B%0D%0A%20%20%20%20return%20class%20StrategyTestInterface%3CP%3E%20extends%20TestInterface%3CP%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20public%20trace%20%3D%20strategy%20%3D%3D%3D%20'A'%20%3F%20TraceA%20%3A%20TraceB%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A)
**Related Issues:** <!-- Did you find other bugs that looked similar? -->
#12510 Cannot access protected members when specifying 'this' type
#17694 Accessing private method with `this` argument specifier